Detect operating system, OS-specific instructions


#1

I’m creating some software that will use either Syphon or Spout (or neither for Linux) and would like to not create three branches. Can one include OS specific compile instructions? Like…

if(APPLE) {
  #include syphon.h
}

and so on?


#2

See https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/utils/ofConstants.h

You can do this:

#ifdef TARGET_LINUX
// code here
#endif

#ifdef TARGET_OSX
#endif

#ifdef TARGET_OF_IOS
#endif

#ifdef TARGET_ANDROID
#endif

#ifdef TARGET_WIN32
#endif

#ifdef TARGET_EMSCRIPTEN
#endif

There are other targets to figure out if you can use threads, the kind of graphics and more.


#3

also,

#ifdef TARGET_OPENGLES
#endif

#4

Is there any way to do this with the addons.make file?