c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

`#if __has_include` in macOS SDK headers causes fatal errors

Open kornelski opened this issue 3 years ago • 1 comments

On macOS Monterey + Xcode 14, system includes use #if __has_include. If the tested header file is missing, c2rust transpile reports a fatal error:

In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:31:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/Availability.h:136:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h:33:19: fatal error: cannot open file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternalPrivate.h': No such file or directory
#if __has_include(<AvailabilityInternalPrivate.h>)

To reproduce:

#include <math.h>

kornelski avatar Sep 15 '22 10:09 kornelski

This is a different issue from #561, because that's for using #if __has_include directly, and I'm still not sure if it's reproducible. This is with system headers. So I've unlinked it in the issue description.

kkysen avatar Sep 15 '22 10:09 kkysen