Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change TARGET_OS_IPHONE preprocessor handling #931

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Conversation

mflatt
Copy link
Contributor

@mflatt mflatt commented Apr 2, 2025

Recent versions of the build tools on macOS define TARGET_OS_IPHONE as 0 when not compiling for iOS.

Closes #896 and #928

c/version.h Outdated
@@ -311,7 +311,7 @@ typedef int tputsputcchar;
#define MMAP_HEAP
#define IEEE_DOUBLE
/* for both iPhone and iPhoneSimulator */
#if defined(TARGET_OS_IPHONE)
#if TARGET_OS_IPHONE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I build this patch on my machine with clang 16, I get warnings like:

gcc -DPORTABLE_BYTECODE -Ipb/boot/pb -Ipb/c -Ic/ -Ipb/zlib -Ipb/lz4/lib -arch arm64 -O2 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -o pb/c/pb.o -c c/pb.c
In file included from c/pb.c:1:
In file included from c/system.h:29:
c/version.h:314:5: warning: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]
  314 | #if TARGET_OS_IPHONE
      |     ^
1 warning generated.

Maybe it would be better to go with #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, ok. I actually tried looking at documentation to make sure that -Wall and -Wextra do not imply -Wundef, and I ran some experiments to check my conclusion. But I had never heard of -Wundef-prefix, and it didn't occur to me that I would need to experiment with a name that starts TARGET_OS_. Thanks again, Apple.

Recent versions of the build tools on macOS define `TARGET_OS_IPHONE`
as 0 when not compiling for iOS, so `#ifdef` needs to be `#if`.
Meanwhile, older versions of macOS tools have
`-Wundef-prefix=TARGET_OS_`, so it's not good to just change `#ifdef`
to `#if`.

Closes cisco#896 and cisco#928
@mflatt mflatt changed the title change TARGET_OS_IPHONE from #ifdef to #if change TARGET_OS_IPHONE preprocessor handling Apr 3, 2025
@mflatt mflatt merged commit ef8879a into cisco:main Apr 7, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build fails with invalid memory reference on x64 darwin and llvm-{18,19}
2 participants