Boost logo

Boost :

Subject: Re: [boost] [preprocessing] Feedback requested on a C99 preprocessor written in pure universal Python
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-03-07 17:19:27


>> Do note pcpp can pass through #if logic which uses undefined macros. So
>> as compiler specific macros will be undefined, all #if logic relating to
>> them passes through. The output is therefore still portable across
>> compilers.
>
> Passing through all #if logic cannot be right !
>
> #if SOME_PREDEFINED_MACRO >= some_value
> some_code
> #endif
>
> #if SOME_PREDEFINED_MACRO < some_value
> some_other_code
> #endif
>
> If both "some_code" and "some_other_code" are passed through I doubt the
> output will be correct.

Edward, it passes through the #if statements and their associated #endif
etc, not just the clauses they wrap.

So basically if it can't execute an #if because the expression contains
an undefined macro, it pass through the entire thing which can be
executed by a later preprocessor.

Does this make sense now?

> I am not trying to minimize your effort in any way in writing pcpp. I am
> just saying that to use it as the preprocessor front-end for various
> compilers is more complicated than I believe you think. Unless pcpp can
> create the same predefined macros which the backend compiler's
> preprocessor creates I doubt if the output can be reliable in many
> situations.

It only part-executes the preprocessor commands, leaving behind the
stuff you tell it.

There is an example of the pass through on the front page of the github
if that helps. It shows the partial execution and pass through of
preprocessor commands.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk