I came across this example of an assertion and was wondering what the #
is for:
#define ASSERT( x ) if ( !( x ) ) { \
int *p = NULL; \
DBGPRINTF("Assert failed: [%s]\r\n Halting.", #x); \
*p=1; \
}
I came across this example of an assertion and was wondering what the #
is for:
#define ASSERT( x ) if ( !( x ) ) { \
int *p = NULL; \
DBGPRINTF("Assert failed: [%s]\r\n Halting.", #x); \
*p=1; \
}
What you see is called stringification. It allows you to convert an argument of a macro into a string literal. You can read more about it here http://gcc.gnu.org/onlinedocs/cpp/Stringification.html.