How can I use #pragma message() so that the message points to the file(lineno)?

前端 未结 6 993
一生所求
一生所求 2021-01-30 09:01

In order to add \'todo\' items into my code, I want to put a message in the compiler output.
I would like it to look like this:

c:/temp/main.cpp(104): TODO -         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 09:36

    Use the # token. I've posted an example from MSDN below:

    // collisions.h
    #define __STR2__(x) #x
    #define __STR1__(x) __STR2__(x)
    #define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "
    
    // collisions.cpp
    #pragma message(__LOC__"Need to do 3D collision testing")
    

提交回复
热议问题