Can I get the preprocessor to keep newlines?
Greetings!
I have a long macro expansion in which I have used backslash/newline sequences to make the definition readable. As I am debugging, I want to see what the preprocessor has done, so I throw a /P into my compiler arguments to get a .i preprocessor output file. Inside the .i file, I see that the macro has been expanded onto a single line. This is, of course, perfectly reasonable C++, but I'd like to have the newlines in the expansion so that I can see it more easily. Is there a way to tell the preprocessor to keep the newlines in the expansion?
Thanks very much!
Rob Richardson
RAD-CON, Inc.
[644 byte] By [
RobR] at [2007-11-20 1:38:40]

# 1 Re: Can I get the preprocessor to keep newlines?
Is there a way to tell the preprocessor to keep the newlines in the expansion?Not that I'm aware of - but is this really a problem? I mean, examining the preprocessor output should usually be a one-time thing, not a recurring activity - so why don't you just take the .i file and add those line breaks manually?
# 2 Re: Can I get the preprocessor to keep newlines?
Maybe a strange question. .. but why do you want to see what the precompiler does ?? As long as you follow the guidelines, you know what the preprocessor does.
Skizmo at 2007-11-10 23:18:49 >

# 3 Re: Can I get the preprocessor to keep newlines?
Maybe a strange question. .. but why do you want to see what the precompiler does ?? Well, it can be useful... Especially to understand how complex or nested macros will be expanded. But this should remain an exceptional thing (while writing those macros), and not something you need to do on a regular basis.
# 4 Re: Can I get the preprocessor to keep newlines?
It doesn't help me much to get a compiler error in a line that says CATCH_ALL_EXCEPTIONS(MyFunctionName). Therefore, I need to look at the preprocessor output to find out exactly where the error occured. Yes, I can (and did) just manually add the line breaks to the .i file, copy the expansion from there, paste it back into the .cpp file and recompile it, but I was hoping there was an easier way.
And in much of this source code, there are #defines that control how the code is built for individual sites. If they get confused, or more likely yet, if a given set of #defines is never even built, the only way to track things down is to look at the preprocessor output. For example, I found one case in which I was getting a linker error on a method that was clearly declared, defined and included in the project. It wasn't until I looked at the preprocessor output that I found out that there was a #ifdef at the top of the class definition's .cpp file preventing the entire body of that file from being built!
Rob Richardson
RAD-CON, Inc.
RobR at 2007-11-10 23:20:47 >
