
Felipe Magno de Almeida wrote:
I see that there are some hooks for appending callbacks for certain situations in the preprocessing. I think this is great. But, I would like to know if it is possible for the user to know when the preprocessor is evaluating an preprocessor conditional, and to know what the condition is.
There is the evaluated_conditional_expression() preprocessing hook getting called whenever a #if/#elif/#ifdef/#ifndef directive was encountered. This hook gets 2 parameters: the (non-expanded) evaluated expression and the outcome of this evaluation (true/false).
Yes, exactly what I need. Have I missed it from the documentation?
It has been added to Wave after the 1.33.1 release only. You can find the description here: http://tinyurl.com/pkz3o (http://boost-consulting.com/boost/libs/wave/doc/class_reference_ctxpolicy.h tml#evaluated_conditional_expression).
And to fork the preprocessing to when the condition is met and when not.
Could you please elaborate on this? I'm not sure what you've meant here.
I would like to continue preprocessing the file but with two different contexts, one with the evaluation being false and another being true.
Hmmm, I'm not sure how this may work. In this case you cannot 'fake' the result of the evaluation of the conditional expression and make Wave behave the way you like. So even if you fork a new process inside the pp hook, you won't be able to tell the new process to take the other condition branch. Even more, this may lead to unexpected behaviour, because you will have situations where you provoke contradictions wrt defined/undefined macros. Regards Hartmut