Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

How to see (or check) values of macro function in C during debugging mode in MS visual studio?

I would like to check a numerical value evaluated by a function macro in C during debugging mode. I defined a function as macro like below.

#define H_H2(T)        0.2584e4*exp(170/(T))

When I tried to evaluate this function H_H2(298) during debugging mode at watch window in Visual studio, it generated an error identifier "H_H2" is undefined.

Could someone let me know how to evaluate a macro function during debugging mode ?

question from:https://stackoverflow.com/questions/65876222/how-to-see-or-check-values-of-macro-function-in-c-during-debugging-mode-in-ms

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can't. Macros are resolved during the preprocessor, and as a result they don't exist in compiled code.

If you need to debug such an expression, create a function, or step through the disassembled code (Ctrl+,G in VS2019).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...