It's common in compilers to define macros to determine what compiler they are, what version is that, ... a portable C++ code can use them to find out that it can use a specific feature or not.
What does
__GNUC__
mean?
It indicates that I'm a GNU compiler and you can use GNU extensions. [1]
What is
__attribute__((unused))
?
This attribute, attached to a variable, means that the variable is meant to be possibly unused. GCC will not produce an unused-variable-warning for this variable. [2]
What is the difference between
__GNUC__
and_MSC_VER
?
They're two unrelated macros. First one says I'm am a GNU compiler and second one says the version number of MS compilers. However, MS compilers are not suppose to support GNU extensions.
How can I do the same
#ifdef
to check whether OS is compiling my python code using GNU and MS visual studios?
#if (defined(__GNU__) && defined(_MSC_VER))
// ...
#endif