SFML community forums

Help => General => Topic started by: Mr.Zeus on January 21, 2019, 09:15:22 pm

Title: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: Mr.Zeus on January 21, 2019, 09:15:22 pm
May I first thank each and every member of the SFML Team and anyone who has contributed to the SFML project for you work. I LOVE SFML so much! :D It gives what may I call "simplistic control," the best kind.  ;)

Now for some context:
I am working on a Pong extension named Pong++. I have set up a game engine/game state manager, and have coded a splash screen. But, when I build I am greeted by this error complaining about the
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
line of "Config.hpp" file(line 54 to be exact). Here is the full error:

/usr/local/include/SFML/Config.hpp:54:9: error: invalid token at start of a preprocessor expression
    #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
        ^
 

I am on MacOS(OS X as it was called at the time of release)version 1.9 (Mavericks), and have SFML 2.5.1 installed. I have not tried reinstalling SFML, but it seems to be an issue with my version of SFML, so if I do I will install the latest commit.

(I did try this in a file just importing the "Config.h" file by itself in a single file and still got an error.)
Title: Re: Build fails due to preprocessor macro in "TargetConditionals.h" file(OSX 1.9.5)
Post by: eXpl0it3r on January 21, 2019, 11:57:02 pm
Odd that nobody else has run into this.
This seems like a code error on our part.  :-\

Try to change the SFML Config.hpp to #if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) and same a few lines down #elif defined(TARGET_OS_MAC).

Let me know if that helps, so we can fix it on master.
Title: Re: Build fails due to preprocessor macro in "TargetConditionals.h" file(OSX 1.9.5)
Post by: Mr.Zeus on January 22, 2019, 12:13:15 am
Thanks; That worked. I a new to C++ and the whole preprocessor thing, sorry if it was obvious. I have worked with Python before and might check out the SFML bindings for it.  ;) Have a nice day/night/evening/morning/afternoon! :P

EDIT: Was this the right category to post this question in? If not, whoops!
Title: Re: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: Laurent on January 22, 2019, 08:10:07 am
According to the documentation inside that header, and various examples found for example on stackoverflow, the original code was right. These macros are always defined, it's their value that must be tested.

Quote
    TARGET_OS_*
    These conditionals specify in which Operating System the generated code will
    run. At most one of the these is true, the rest are false.
Title: Re: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: eXpl0it3r on January 22, 2019, 08:23:52 am
Hmm interesting, but then I wonder, are the ones for iOS always required to exist? Like isn't there an option to install XCode or similar without iOS support?

Maybe we should move the macOS check up or check if defined first and only then check the value?
Title: Re: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: Laurent on January 22, 2019, 08:53:25 am
All the versions of that file that I could find, always define all these macros (unconditionally).

Mr.Zeus, maybe you should investigate what happens in your specific environment, since you're the only one who gets this error. You can post the content of your TargetConditional.h header for example, or post a preprocessed version of Config.hpp.
Title: Re: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: Mr.Zeus on January 22, 2019, 04:37:09 pm
Here is my TargetConditionals.h file in full:

(click to show/hide)

Now I don't quite know what you mean by "preprocessed version of Config.hpp." but I assume you mean a list of the values of the defines. How might I get that? (Again, new to C++, sorry.) Just point me in the right direction and will get them to you ASAP.

Oh, also, I am not using XCode or have installed its Developer Tools(I am using VS Code: https://code.visualstudio.com/). I moved the SFML include(named "SFML", of course) directory right into my "/usr/local/include" directory. Should I have done that? :-\
Title: Re: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: Laurent on January 22, 2019, 05:46:49 pm
Quote
Now I don't quite know what you mean by "preprocessed version of Config.hpp."
You can invoke the compiler on a source file, with specific flags, so that it outputs the preprocesses version of that file, ie. with only the preprocessor pass done (not compiled). The goal is to know how the preprocessor replaces those macros in Config.hpp.
Title: Re: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file
Post by: Mr.Zeus on January 22, 2019, 06:23:44 pm
The preprocessor passed "Config.hpp" file:

(click to show/hide)

Hope it helps!