ifdef __linux__ / gtk issue; how to list defined symbols for cmake?

Gary Aitken freebsd at dreamchaser.org
Tue Jun 25 03:57:04 UTC 2019


I'm working on porting the prusa slicer.  It contains a boatload of
things like
   #if defined _WIN32
     ...
   #elif defined(__linux__)
     ...
   #elif defined __APPLE__
     ...

occasionally there is a

   #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)

or a
   #ifdef __unix__

or a
   #ifdef __WXGTK__    (for wxwidgets toolkit mapped to gtk)

It appears that many of the issues for __linux__ are actually gtk issues
which I *think* should be common to linux and bsd under gtk on X.

Questions:

1.  Is there an easy way to get a list of all the __*__ symbols?
     Where / how are these set up?
     Is there a way to list them at the start of compilation of each file
     to check the appropriate ones are all defined in different subdirs
     of the build tree?

2.  I'm guessing/hoping the sym definitions are a general configuration
     process that mostly happens the same way across all ports.
     If __linux__ is defined, is __unix__ also defined?  If any of the
     __*BSD__ syms are defined, is __unix__ also defined?

3.  What's the relationship between the _WIN32, __APPLE__, __unix__ type
     syms in code and the WIN32, APPLE, UNIX, XCODE syms that I see in
     some of the CMakeLists.txt files?  Are any/all of these case sensitive?
     How is CMAKE_SYSTEM_NAME, which may be "Linux" (on linux), related to
     the above syms?

4.  Suggestions on how to approach this?  I'm inclined to change the
       "#if defined(__linux__)" to "#if defined(__WXGTK__)" where appropriate
     instead of adding
       "|| defined(__FreeBSD__) || defined(__NetBSD__)..." etc.
     Is there a "BSD" sym that encompasses the various bsd variants?

thoughts / suggestions / things to be careful of?

Thanks,

Gary


More information about the freebsd-ports mailing list