Take the 2-minute tour ×

(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.

(I will mark my answer as correct when I'm allowed to. Other approaches welcome, I looked at __attribute__((warning)) but couldn't get it to work.)

share|improve this question

1 Answer 1

up vote 27 down vote accepted

It's very easy to do:

#warning Needs better error handling, please.
share|improve this answer
You can also use #error Message to trigger build errors. –  ughoavgfhw Jun 2 '11 at 20:22
This isn't really a good idea, as it makes warnings a regular part of the build rather than indications of possible errors. You'd be better off using //FIXME or //TODO, which many IDEs automatically pick up, to mark sections of code that need work. –  jshier Jun 2 '11 at 23:50
@jshier I consider it developer error (or at least I would only mark ones that I consider developer error.) The idea is to help others (and myself) get better at error handling so as do the right thing going forward. The warnings will disappear when they're addressed, and I think they need to be addressed. I don't think //FIXME and //TODO are strong enough. –  zekel Jun 8 '11 at 18:10
(Also, when you're working on a small enough team it makes more sense and isn't obnoxious because it's only seen by your target audience.) –  zekel Jun 30 '11 at 14:38
Just be careful when you use //FIXME or //TODO. You need to add a colon at the end. The right syntax is: //FIXME: fix me comment and // TODO: to do comment –  Designerd Oct 4 '11 at 19:20

Your Answer


