outputing code path at preprocesser time

Started by
4 comments, last by _walrus 19 years, 6 months ago
Hi, is there a tool that allows for the input of c/c++ code and it outputs only the code from the path set by the preprocessor flags. I have some code that i want to cut out all the code paths that dont get compiled. thanks
Advertisement
Do you mean you don't want to compile some files or parts in some files?

- Patrik Willbo
no what i mean is that i i want to generate a source file that containes the original source minus all the code that is ommited from by the preprocessor.


for instance if i had a file:
#define LINUX

#if defined(LINUX)
foo();
foo();
foo();
#else
boo();
boo();
boo();
#endif


the tool would produce

foo();
foo();
foo();


I want this cause i i have some C source (actually a lot) that i want to port to Java. I want to do this fast so i want to get rid of as much clutter as possible (i'm only porting one specific) compile path over. For instance this thing has build paths for 64 bit processor, asm,... etc and i wwant to get ride of this stuff using some automated process. I'm sure there's gotta be a tool out there that does this cause its pretty much just running the copiler with out the syntactic transduction.
Quote:Original post by _walrus
Hi, is there a tool that allows for the input of c/c++ code and it outputs only the code from the path set by the preprocessor flags. I have some code that i want to cut out all the code paths that dont get compiled. thanks

The C-language FAQ has a short section on selective preprocessors.
The previous post was mine. Firefox just doesn't want to keep me logged in today..

Quote:Original post by _walrus
Hi, is there a tool that allows for the input of c/c++ code and it outputs only the code from the path set by the preprocessor flags. I have some code that i want to cut out all the code paths that dont get compiled. thanks

The C-language FAQ has a short section on selective preprocessors.
Quote:Original post by doynax
The previous post was mine. Firefox just doesn't want to keep me logged in today..

Quote:Original post by _walrus
Hi, is there a tool that allows for the input of c/c++ code and it outputs only the code from the path set by the preprocessor flags. I have some code that i want to cut out all the code paths that dont get compiled. thanks

The C-language FAQ has a short section on selective preprocessors.



Perfect thats exacty what i want. Thanks a million!!

This topic is closed to new replies.

Advertisement