分享一个编译期输出TODO,FIXME列表的宏

效果,双击能跳到相应位置:

1>------ Build started: Project: TestVS2013, Configuration: Debug Win32 ------
1>  TestMain.cpp
1>  
1>  ====================================
1>  d:\testprojects\testvs2013\testvs2013\testmain.cpp(20)
1>  TODO : not implements now !
1>  ====================================
1>  
1>  
1>  ====================================
1>  d:\testprojects\testvs2013\testvs2013\testmain.cpp(21)
1>  HACK : this function is implemented by a hack way!
1>  ====================================
1>  
1>  
1>  ====================================
1>  d:\testprojects\testvs2013\testvs2013\testmain.cpp(22)
1>  FIXME : buggy ! !
1>  ====================================
1>  
1>  TestVS2013.vcxproj -> D:\TestProjects\TestVS2013\Debug\TestVS2013.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

测试代码:

#define TOOLS_STRINGSIZE( L ) #L
#define TOOLS_MAKESTRING_IMP( M, L ) M(L)
#define TOOLS_MAKESTRING(x) TOOLS_MAKESTRING_IMP(TOOLS_STRINGSIZE,x)
#define TOOLS_MESSAGE_LINE "\n====================================\n"
#define TOOLS_MESSAGE_POSITION __FILE__ "(" TOOLS_MAKESTRING(__LINE__) ")\n"
#define WHAT(type,content) message (TOOLS_MESSAGE_LINE TOOLS_MESSAGE_POSITION type content TOOLS_MESSAGE_LINE)
#define TODO(content) WHAT("TODO : ",content)
#define WARNING(content) WHAT("WARNING : ",content)
#define HACK(content) WHAT("HACK : ",content)
#define FIXME(content) WHAT("FIXME : ",content)

#pragma TODO("not implements now !")
#pragma HACK("this function is implemented by a hack way!")
#pragma FIXME("buggy ! !")

int main(int argc, char* argv[])
{
    return 0;
}
posted @ 2014-04-30 17:44  *神气*  阅读(536)  评论(0编辑  收藏  举报