To Be Done Macro

Use the following marker
  not_yet_coded;
in your C++ - code as a cure for ForgetToFixItLater.

 #define not_yet_coded  do   { cerr << "Error: " << __FILE__ <<     ", line " << __LINE__ << "\n";   throw whatever();  }   while(0)

That do/while - construct makes it a single statement.

-- AndreasKrueger


Leaving other issues aside for the moment, this should probably be phrased to result an expression, like assert:

 #define not_yet_coded    void((cerr << "Error: " << __FILE__ <<     ", line " << __LINE__ << "\n"),        throw whatever())

Alternatively, one could build on assert directly if one so wished:

 assert(!"not yet coded");

--KevlinHenney


One answer might be to write something like,

 #include <stdlib.h>
 #include <stdio.h>
 #ifdef NDEBUG
 #define FIXME(x) FIXME
 /* If you prefer detecting errors at runtime, uncomment this
 #define FIXME(x) do { fprintf( stderr, "FIXME (%s, %d): %s\n", __FILE__, __LINE__, #x ); exit( EXIT_FAILURE ); } while(0)
 */
 #else
 #define FIXME(x) fprintf( stderr, "FIXME (%s, %d): %s\n", __FILE__, __LINE__, #x )
 #endif

...

FIXME( Detect connection drop. )

so that in release mode, you will definitely know that the code should be fixed. Considering my approach to ConfigurationManagement, this would ensure the code was fixed before you checked it in or else you'd be hit with a flying pencil. -- SunirShah


Try using:

 #if FIXME
 #endif

Note the use of "#if" not #ifdef", also FIXME is undefined. In many compilers, this will generate a warning message, making the FIXME comments very hard to forget.

Why use this in preference to #warning?

[It should not be; only a language lawyer could even tell you whether #if on an undefined symbol is explicitly allowed by the standard, explicitly disallowed, UndefinedBehavior, or what.]

[Any way of generating a warning is not a good idea, since many shops have a policy that warnings should be treated as errors -- with good reason, due to the widespread experience that warnings signal CodeSmells and can mask serious problems. "Yeah, I know we have 2,000 lines of warning output when we compile, that's normal." Fixing the code so that all the warnings go away invariably fixes a certain number of longstanding mysterious "unfixable" bugs.]

[Therefore, at most one should do:]

  #ifdef TRIGGER_FIXME_COMPILER_WARNINGS   /* normally an undefined symbol */
  #warning "fixme blah blah"
  #endif

[...or the similar but fancier code mentioned near start of page.]

[Consider further that the whole idea of FIXME is a deferred fix, otherwise one would just fix the code and not need a FIXME of any sort, so why ask for warnings on a topic you already know you are not ready to deal with yet? One merely gets desensitized and learns to ignore such things, which really is not a good idea.]

[Or, if it's a really critical thing, and you're trying to remind yourself/the team that something really, really, really needs to be fixed ASAP, then just use #warning, period. Or better yet, #error.]
Some content moved from FixmeComment

EditText of this page (last edited August 11, 2005) or FindPage with title or text search