Skip to content

Commit 0d53a68

Browse files
committed
base: forward declare struct _stat for Windows
We need to forward declare the struct as otherwise the definition is local to the declaration and cannot be defined. This addresses the `-Wvisibility` warning when building for Windows.
1 parent 0b1dbef commit 0d53a68

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CoreFoundation/Base.subproj/CoreFoundation_Prefix.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ void OSMemoryBarrier();
287287
#define CF_PRIVATE extern
288288

289289
#define __builtin_expect(P1,P2) P1
290-
290+
291+
#include <sys/stat.h>
292+
291293
// These are replacements for POSIX calls on Windows, ensuring that the UTF8 parameters are converted to UTF16 before being passed to Windows
292294
CF_EXPORT int _NS_stat(const char *name, struct _stat *st);
293295
CF_EXPORT int _NS_mkdir(const char *name);

CoreFoundation/Base.subproj/ForFoundationOnly.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,14 @@ typedef CFTypeRef _Nonnull (*CFErrorUserInfoKeyCallBack)(CFErrorRef err, CFStrin
422422
CF_EXPORT void CFErrorSetCallBackForDomain(CFStringRef domainName, CFErrorUserInfoKeyCallBack _Nullable callBack) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
423423
CF_EXPORT CFErrorUserInfoKeyCallBack _Nullable CFErrorGetCallBackForDomain(CFStringRef domainName) API_AVAILABLE(macos(10.5), ios(2.0), watchos(2.0), tvos(9.0));
424424

425-
#if DEPLOYMENT_TARGET_WINDOWS
425+
_CF_EXPORT_SCOPE_END
426+
426427
// ---- Windows-specific material ---------------------------------------
428+
#if DEPLOYMENT_TARGET_WINDOWS
429+
430+
#include <sys/stat.h>
431+
432+
_CF_EXPORT_SCOPE_BEGIN
427433

428434
// These are replacements for POSIX calls on Windows, ensuring that the UTF8 parameters are converted to UTF16 before being passed to Windows
429435
CF_EXPORT int _NS_stat(const char *name, struct _stat *st);
@@ -436,10 +442,11 @@ CF_EXPORT char *_NS_getenv(const char *name);
436442
CF_EXPORT int _NS_rename(const char *oldName, const char *newName);
437443
CF_EXPORT int _NS_open(const char *name, int oflag, int pmode);
438444
CF_EXPORT int _NS_mkstemp(char *name, int bufSize);
439-
#endif
440445

441446
_CF_EXPORT_SCOPE_END
442447

448+
#endif
449+
443450
// ---- Miscellaneous material ----------------------------------------
444451

445452
_CF_EXPORT_SCOPE_BEGIN

0 commit comments

Comments
 (0)