-5

I was trying to detect target operating system using c macros _WIN32 and _ CYGWIN_ but it shows error that _ CYGWIN_ is undeclared. How to use these macros to find target operating system

Durgesh
  • 29
  • 4

2 Answers2

2

gcc on cygwin defines the macro __CYGWIN32__.

Take a look at GCC dump preprocessor defines to find all the macros defined by the preprocessor.

Community
  • 1
  • 1
R Sahu
  • 204,454
  • 14
  • 159
  • 270
2

Try using #ifdef. For example:

#ifdef __CYGWIN__
  // Cygwin specific code
#else
  // Other code
#endif
David S.
  • 518
  • 3
  • 5