Question

I'm attempting to use a /D compiler option on MSVC6 to define a string, but there's something weird about using double quotes around it. To debug this problem, it would be extremely helpful for me to be able to see what value the preprocessor is actually substituting into my code where the macro is expanded. Is there any way I can do this? I tried creating a Listing file with "assembly and source", but the source contains the original macro name and the ASM is some incomprehensible gibberish at that line. Is there a way to get the macro value at compile time?

Failing that (or perhaps more useful), how do I specify a string with the /D option? It needs to substitute into my source with double quotes around it, since I'm using it as a string literal.

Was it helpful?

Solution

Try one of the following options to CL.exe:

/E preprocess to stdout
/P preprocess to file

If you're building within Visual Studio, you can specify custom command-line options in one of the project property dialogs.

OTHER TIPS

MSVC has a compiler flag that allows you to see the preprocessed source file with all the macros expanded, comments removed, etc. - the entire translation unit in terms of the actual code that will compile. Preprocessed output should give you the insight you're looking for regarding your macro expansion. More info here.

There's an option to pass to the compiler (/P) and it will write the preprocessor output into my_cpp_file.i where you can look at it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top