Can you add custom compiler warnings in Objective-C?

zekel picture zekel · Jun 2, 2011 · Viewed 10.5k times · Source

(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

zekel picture zekel · Jun 2, 2011

It's very easy to do:

#warning Needs better error handling, please.