“Selectively Disable Warnings” with clang

Kick ass compiler!

I saw this demo done at WWDC on how to turn off warnings, only when truly warranted, while compiling with clang:

#if defined (__clang__)
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wunused-value"
#endif // defined __clang__

void ImAUselessLittleFunction ( int pleaseUseMe )
{
    pleaseUseMe; // Nope, you are not going to be used
}
#if defined (__clang__)
    #pragma clang diagnostic pop
#endif // defined __clang__

I thought this should be shared with you… You’re welcome 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *