Click here to Skip to main content
Licence CPOL
First Posted 21 May 2009
Views 18,385
Bookmarked 28 times

FIXME - A Smart FIXME Macro

By | 25 May 2009 | Article
Using this smart 'FIXME' macro will help you not to forget to fix your code.

Introduction

If you are using Visual Studio, this FIXME macro will help you not to forget to fix your code before you release it. During debug build, this macro will be ignored; during release build, you will get an error message which will point to the code you need to fix. You can use this macro to remind you, for example, to update the version string, or to fix some debug code which should not be part of the release build.

Example

#include "stdafx.h"
#include <windows.h>

FIXME //update version string before release
int _tmain(int argc, _TCHAR* argv[])
{
  FIXME
  printf("password is *bill*\n");
  return 0;
}

The above code will produce the following output during release build:

1>building...
1>test.cpp
1>.\test.cpp(4) : error C666: found FIXME in release build!
1>.\test.cpp(8) : error C666: found FIXME in release build!
1>pragmatest - 2 errors, 0 warnings
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

You can click on the error message to jump directly to the FIXME keyword.

How It Works

Put the following code into stdafx.h:

#define __STR2__(x) #x
#define __STR1__(x) __STR2__(x)
#define __LOC2__ __FILE__ "("__STR1__(__LINE__)") : "

#ifdef NDEBUG
  #define FIXME __pragma(message(__LOC2__ "error C666: found FIXME in release build!"))
#else
  #define FIXME
#endif

The FIXME macro is defined depending on if you make a debug or release build. On debug build, #define FIXME is used, which does nothing. On release build, pragma(message(__LOC2__ "error C666: found FIXME in release build!")) is set. It will display the file and the line number of the FIXME macro in the output window. The trick to display a clickable error message is from the Message with style article.

History

  • 21st May, 2009: Initial post
  • 22nd May, 2009: Minor update

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jochen Baier



Germany Germany

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralAuthors Tip: exclude macro definition from Visual Studio text search PinmemberJochen Baier6:27 1 Nov '09  
GeneralTip: This can be useful for a lot more than just pragmas PinmemberMember 446276422:27 9 Jun '09  
GeneralTip Pinmemberalex__b5:29 5 Jun '09  
GeneralNot working PinmemberDaTxomin17:07 24 May '09  
GeneralRe: Not working PinmemberJochen Baier23:05 24 May '09  
GeneralRe: Not working PinmemberDaTxomin0:56 25 May '09  
GeneralRe: Not working PinmemberDaTxomin1:22 25 May '09  
GeneralRe: Not working PinmemberJochen Baier6:23 7 Jun '09  
GeneralRe: Not working Pinmembernenfa2:52 2 Aug '10  
QuestionVery nice, but could it be enhanced? PinmemberWilli Deutschmann11:29 22 May '09  
AnswerRe: Very nice, but could it be enhanced? PinmemberJochen Baier12:21 22 May '09  
GeneralRe: Very nice, but could it be enhanced? Pinmemberzengkun10021:52 8 Jun '09  
Generalvery cool Pinmemberjeffie1009:52 22 May '09  
GeneralNice, simple, and straightforward PinmemberHarold Bamford8:14 22 May '09  
GeneralRe: Nice, simple, and straightforward PinmemberJochen Baier12:51 22 May '09  
GeneralRe: Nice, simple, and straightforward Pinmemberfeanorgem15:45 2 Jun '09  
GeneralRe: Nice, simple, and straightforward PinmemberJochen Baier6:26 7 Jun '09  
GeneralRe: Nice, simple, and straightforward Pinmemberfeanorgem9:29 7 Jun '09  
GeneralRe: Nice, simple, and straightforward Pinmemberzengkun10017:28 7 Jun '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 25 May 2009
Article Copyright 2009 by Jochen Baier
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid