This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can CPP process only one "conditional" ?




Fabian Cenedese wrote:
> 
> At 00:47 11.06.2008 -0700, adlv wrote:
> 
>>Hello
>>
>>I want to give the source code of my software (written in C and C++),
either
>>in a freeware version or in a shareware version.
>>
>>I could put something like this in my code :
>>
>>#if FREE_VERSION
>> Âcode A...
>>#else
>> Âcode B...
>>#endif
>>
>>then source files with the "code A" part would be given with the freeware
>>package.
>>and source files with the "code B" part would be given with the shareware
>>package.
>>
>>I am wandering if CPP can generate output files corresponding to these two
>>different versions of my source code. In other words I would like CPP to
>>process only this conditional statement (FREE_VERSION), and _only_ this
one!
>>
>>In other words :) I would like CPP to give the exact same output files as
>>it's input files, except for this specific conditional.
>>
>> From what I have read in the CPP documentation and some faqs, I don't
>> think
>>CPP can do the job. But if someone here thinks it can, then it would make
>>mine easier :)
> 
> You may want to give doxygen a try. It includes a preprocessor and can
> be configured what macros to expand. That may give you the processed
> source files as you want (and some nice documentation as well :)
> 
> I have never used it for that purpose but I think it can do it.
> 
> If that doesn't work you may want to write a script to filter the text
> files.
> sed can probably do it.
> 
> bye  Fabi
> 

Thank you Fabi. Here is some feedback on the ideas you suggested.

Using sed seems difficult because it is mainly aimed at line after line
processsing.
awk might be able to do it, although it would require some script
programming.

Doxygen's preprocessor is a very good candidate, as it seems to be doing
exactly what I want with the tag EXPAND_ONLY_PREDEF.
More info here : http://www.stack.nl/~dimitri/doxygen/preprocessing.html

That solves my question, although I would be curious to know if CPP can do
the equivalent of doxygen.

Best regards
-- 
View this message in context: http://www.nabble.com/Can-CPP-process-only-one-%22conditional%22---tp17771975p17779209.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]