Is there a way to both check a macro is defined and it equals a certain value at the same time

This may not work for the general case (I don’t think there’s a general solution to what you’re asking for), but for your specific example you might consider changing this sequence of code:

#if(DEBUG_PRINT == 1)
    printf("%s", "Testing");
#endif

to:

if (DEBUG_PRINT == 1) {
    printf("%s", "Testing");
}

It’s no more verbose and will fail to compile if DEBUG_PRINT is not defined or if it’s defined to be something that cannot be compared with 1.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)