Fix building with clang 15 on OSX #609#610
Merged
saudet merged 2 commits intobytedeco:masterfrom Sep 29, 2022
Merged
Conversation
Member
|
Thanks for the fix! To make sure we don't break anything, we probably want more something like this though: --- a/src/main/java/org/bytedeco/javacpp/tools/Generator.java
+++ b/src/main/java/org/bytedeco/javacpp/tools/Generator.java
@@ -315,6 +315,8 @@ public class Generator {
out.println("#elif defined(__APPLE__) && defined(__OBJC__)");
out.println(" #include <TargetConditionals.h>");
out.println(" #include <Foundation/Foundation.h>");
+ out.println("#elif defined(__APPLE__)");
+ out.println(" #include <TargetConditionals.h>");
out.println("#endif");
out.println();
out.println("#ifdef __linux__"); |
Contributor
Author
|
Great, I've overwritten the commit with what you have requested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem is explained in the issue, but to reiterate:
Newer versions of apple's clang will error if there is an undefined reference to TARGET_OS_*. The solution to this is to include the
TargetConditionals.hfile ahead of any references. The problem originates here:javacpp/src/main/java/org/bytedeco/javacpp/tools/Generator.java
Lines 313 to 318 in f77f8d7
The
TargetConditionals.his only included if both__APPLE__and__OBJC__are definied. If you use a brew installed llvm (currently version 15), the__APPLE__will be defined but__OBJC__is not.What I have done is made it so that
TargetConditionals.his always included on apple, and theFoundation/Foundation.his only included when__OBJC__is defined. The result is this:I've tested this on OSX 12.6, clang 15 (installed via
brew install llvm).