Fix <folly/portability/Windows.h> on Windows SDK 1903 / 10.0.18362.0
Summary: Folly does not compile with Windows SDK 1903. The issues is in folly/portability/Windows.h and surfaces when compiling files including it, e.g.: xplat/folly.portability/Stdlib.cpp ``` xplat\folly/portability/SysStat.h:47:5: error: conflicting types for 'mkdir' int mkdir(const char* fn, int mode); ^ C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\direct.h:111:26: note: previous declaration is here _ACRTIMP int __cdecl mkdir( ^ xplat\folly\portability\Stdlib.cpp:47:11: error: no matching function for call to 'mkdir' ret = mkdir(ptr, 0700); ^~~~~ C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\direct.h:111:26: note: candidate function not viable: requires single argument '_Path', but 2 arguments were provided _ACRTIMP int __cdecl mkdir( ^ 2 errors generated. ``` Now internal Windows functions collide with folly portability ones defined in https://github.com/facebook/folly/blob/master/folly/portability/Unistd.h#L61-L93 C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\direct.h defines a Windows ```mkdir``` function when ``` #if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES //... _Check_return_ _CRT_NONSTDC_DEPRECATE(_mkdir) _ACRTIMP int __cdecl mkdir( _In_z_ char const* _Path ); _Check_return_ _CRT_NONSTDC_DEPRECATE(_rmdir) _ACRTIMP int __cdecl rmdir( _In_z_ char const* _Path ); #endif // _CRT_INTERNAL_NONSTDC_NAMES ``` When diffing the current Windows SDK 1903 version: C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt\corecrt.h with a previous one, e.g.: 1809 C:\tools\toolchains\vs2017_15.9\WindowsSdk\Include\10.0.17763.0\ucrt\corecrt.h we see a fundamental change: ## SDK 1903 ``` #if ( defined _CRT_DECLARE_NONSTDC_NAMES && _CRT_DECLARE_NONSTDC_NAMES) || \ (!defined _CRT_DECLARE_NONSTDC_NAMES && !__STDC__ ) #define _CRT_INTERNAL_NONSTDC_NAMES 1 #else #define _CRT_INTERNAL_NONSTDC_NAMES 0 #endif ``` ## SDK 1809 ``` #define _CRT_INTERNAL_NONSTDC_NAMES \ ( \ ( defined _CRT_DECLARE_NONSTDC_NAMES && _CRT_DECLARE_NONSTDC_NAMES) || \ (!defined _CRT_DECLARE_NONSTDC_NAMES && !__STDC__ ) \ ) ``` Reviewed By: Orvid Differential Revision: D19804183 fbshipit-source-id: cbbe32c611a3c011175145329c29de4a9597868c
Showing
Please register or sign in to comment