How to debug macros efficiently in VS?

前端 未结 9 1898
情书的邮戳
情书的邮戳 2021-02-01 22:38

I\'ve got a pretty complicated macro inside my (unmanaged) C++ code. Is there any way to expand macros in VS debugger? Or maybe there is another way to debug macros there?

9条回答
  •  没有蜡笔的小新
    2021-02-01 22:50

    I learned from http://www.codeproject.com/Tips/320721/Macro-expansion-in-VCplusplus the best way to debug macros.

    And what i do is to create a cxx file named "test.cxx" and inside i only put the macro and a some uses example of a test.cxx:

    #define GetMacro(param1) \
      public: void Get##param1(){ return m_##param1; }
    
    GetMacro(MyVariable);
    

    and in a command line i enter:

    c:\ cl /EP test.cxx > output.cxx
    

    When i open the output.cxx file there should be some blank lines and at the bottom the expanded macro, like:

    public: void GetMyVariable(){ return m_MyVariable; };
    

    You can test macros without compiling and that makes it quick.

提交回复
热议问题