LB40
LB40

Reputation: 12331

Is there a way to debug preprocessed code in VisualStudio

I've a visual C++ project I'd like to debug. However, several functions are actually generated by macro expansion ( like set##Name for a particular property). So, while debugging I can't follow the execution flow inside these generated functions.

Do I have to use the /P flag and then debug the preprocessed code?

Upvotes: 1

Views: 622

Answers (1)

sbi
sbi

Reputation: 224129

You would have to preprocess the code using the /P flag in some other project (or on the command line, if you fancy spelling out all the include and library folders), and then compile this preprocessed code instead of the source file in your real project. Then you can debug through it.

That said, once you're at it, can't you eliminate the macros? With const, inline, and templates, I rarely ever feel the need to resort to macros, and if I do, it's usually very small, isolated pieces of code. These are either too trivial to need debugging, or I manually replace one instance of the macro with the code it generates and debug that. (However, this might have happened to me thrice in the last decade.)

Upvotes: 2

Related Questions