zekel zekel - 4 months ago 9
Objective-C Question

Can you add custom compiler warnings in Objective-C?

(I found the answer to this elsewhere while writing the question, but I thought it might be helpful to others if I posted it since I couldn't find anything here.)

I want to mark methods that need better error handling. I'd like them to show up as compiler warnings so other developers (who may be responsible for that area) will notice, and hopefully fix at their leisure.

(Other approaches welcome, I looked at

__attribute__((warning))
but couldn't get it to work.)

Answer

It's very easy to do:

#warning Needs better error handling, please.
Comments