Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED]Build fails due to preprocessor macro in "TargetConditionals.h" file  (Read 4845 times)

0 Members and 1 Guest are viewing this topic.

Mr.Zeus

  • Newbie
  • *
  • Posts: 6
  • Oh, a flavour text...
    • View Profile
    • Email
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.)
« Last Edit: January 22, 2019, 02:50:43 am by Mr.Zeus »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mr.Zeus

  • Newbie
  • *
  • Posts: 6
  • Oh, a flavour text...
    • View Profile
    • Email
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!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
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.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
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.
Laurent Gomila - SFML developer

Mr.Zeus

  • Newbie
  • *
  • Posts: 6
  • Oh, a flavour text...
    • View Profile
    • Email
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? :-\

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
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.
Laurent Gomila - SFML developer

Mr.Zeus

  • Newbie
  • *
  • Posts: 6
  • Oh, a flavour text...
    • View Profile
    • Email
The preprocessor passed "Config.hpp" file:

(click to show/hide)

Hope it helps!

 

anything