What does the pound sign indicate in this line of code?
#define CONDITION(x) if(!(x)){ HandleError(#x,__FUNCTION__,__LINE__);return false;}
This is how it is being called:
CONDITION(foo != false);
A single #
before a macro parameter converts it to a string literal.
#define STRINGIFY(x) #x
STRINGIFY(hello) // expands to "hello"
In your example, the string would be "foo != false"
, so that the error message shows the code that was being tested.
A double ##
between two tokens within a macro combines them into a single token
#define GLOM(x,y) x ## y
GLOM(hello, World) // expands to helloWorld
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With