Search code examples
clangpragmallvm-clang

Disable -Werror via pragma clang diagnostic


Using -Werror to treat all warning as errors, I don't want to suppress a deprecated declaration warning :

#pragma clang diagnostic push
#pragma clang diagnostic ignore "-Wdeprecated-declarations"
    SKPayment *myPayment = [SKPayment paymentWithProductIdentifier:completeName];
    [[SKPaymentQueue defaultQueue] addPayment:myPayment];
#pragma clang diagnostic pop

How to do it ?


Solution

  • Ok, found it, just use warning instead of ignore :

    #pragma clang diagnostic push
    #pragma clang diagnostic warning "-Wdeprecated-declarations"
        SKPayment *myPayment = [SKPayment paymentWithProductIdentifier:completeName];
        [[SKPaymentQueue defaultQueue] addPayment:myPayment];
    #pragma clang diagnostic pop
    

    Now, I still use this deprecated API, compilation passes with -Werror and warning is still present (remove this API use is kept in mind).