When exploring a source package, I discovered that some if statements were defined by preprocessor directives and then used in the code like the example below:
#ifdef _WIN32
#define OSisWindows() true
#define OSisLinux() false
#elif defined(__linux__)
#define OSisLinux() true
#define OSisWindows() false
#endif
if ( OSisWindows() )
{
// do something
}
if ( OSisLinux() )
{
// do something else
}
Is there a difference between using this and simple defines like _WIN32 or __linux__ ?
bool OSisWindows() {return true;}works just as well.inlineand that wouldn't be an issue either.inline.(OSisWindows)()