Board index » Visual Studio » Preprocessor Question in Visual Studio 2003

Preprocessor Question in Visual Studio 2003

Visual Studio60
Hi, I'm looking at moving a c/c++ project from Linux to Windows. One of

the things we have in the linux version is an xml file that is parsed

by a custom perl script to generate a .c and .h file that contains

configuration structures.



This xml file contains default values for attributes that are actual

#defines in other header files in the project. As a result we parse the

.xml file with the c preprocessor 'cpp'. Then throw the resulting .xmlp

file into our perl script.



How could this preprocessing step be accomplished in visual studio

2003?? Is its preprossor able to parse and xml file or is there a win32

equivalent of cpp.



Thanks


-
 

Re:Preprocessor Question in Visual Studio 2003

<colin.goudie@gmail.com>wrote:



Quote
Hi, I'm looking at moving a c/c++ project from Linux to Windows. One of

the things we have in the linux version is an xml file that is parsed

by a custom perl script to generate a .c and .h file that contains

configuration structures.



This xml file contains default values for attributes that are actual

#defines in other header files in the project. As a result we parse the

.xml file with the c preprocessor 'cpp'. Then throw the resulting .xmlp

file into our perl script.



How could this preprocessing step be accomplished in visual studio

2003?? Is its preprossor able to parse and xml file or is there a win32

equivalent of cpp.



Thanks



There are at least two options that I know of... The one that immediately

jumps to mind is to install Cygwin and just use cpp. However, I believe

that you can do this with VS (I used VS.NET 2003). I created a text file

named temp.txt...



<temp.txt>

#define test TEST THAT WORKED

This is a test

</temp.txt>



Then I ran the VC compiler with the following command line...



<command>

cl /nologo /EP /C temp.txt>output.txt

</command>



In case you're not familiar with VS, those parameters are...

/nologo - don't display the compiler logo

/EP - pre-process to stdout with no #line's

/C - don't strip comments



The contents of output.txt were...



<output.txt>

This is a TEST THAT WORKED

</output.txt>



I've never tried this with VS before, but it appears to work fine. Just for

giggles I changed the source file name to temp.xml to make sure nothing

goofy happened. Also, since I have Cygwin installed, I was able to get the

same results with the command line



<command>

cpp -E -P temp.txt>output.txt

</command>



So it would appear that you can go either way on Windows.



Craig





-

Re:Preprocessor Question in Visual Studio 2003

Thanks so much for that. I didnt expect anyone to put that much effort

into it but that is much appreciated. Thanks



-

Re:Preprocessor Question in Visual Studio 2003

<colin.goudie@gmail.com>wrote:



Quote
Thanks so much for that. I didnt expect anyone to put that much effort

into it but that is much appreciated. Thanks



You're very welcome!



Craig





-