How do I check OS with a preprocessor directive?

I need my code to do different things based on the operating system on which it gets compiled. I’m looking for something like this: #ifdef OSisWindows // do Windows-specific stuff #else // do Unix-specific stuff #endif Is there a way to do this? Is there a better way to do the same thing? 16 Answers … Read more

How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor? [duplicate]

This question already has answers here: How do I check OS with a preprocessor directive? (16 answers) Closed 2 years ago. The community reviewed whether to reopen this question 3 months ago and left it closed: Original close reason(s) were not resolved If there’s some cross-platform C/C++ code that should be compiled on Mac OS … Read more