“Selectively Disable Warnings” with clang

0

Posted by Jaime | Posted in Coding | Posted on 04-04-2012

Tags: , , ,

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 🙂