Re: [boost] Partial preprocessing for Fusion, et.al. (was: [netlib] Update: 0.9 will not be header-only)

On Sun, Dec 5, 2010 at 2:02 AM, joel falcou <joel.falcou@lri.fr> wrote:
In my own experience, problem lies in Proto/MPL/Fusion preprocessor time more than anything else. MPL became managable thansk to the preprocessed headers, maybe Fusion,Proto and maybe Spirit should do the same
+1
Does anybody have an idea on how this can be done? I seem to recall that GCC only had options for preprocessing when compiling an object file -- that would mean for making a .cpp file for each of the headers that need to be pre-processed independently, running it through the compiler's preprocessor (or wave) to get the appropriate output.
Maybe someone already has a script to do that which can be adapted?
What everybody is looking for is partial preprocessing, i.e. expansion of only some of the macros. Wave does not directly support this (does any preprocessor?), but you can do is to use #pragmas to enable/disable output generation. This creates the effect of partially expanding only a subset of the input. Here is an example: File: example.hpp: // stuff here will be preprocessed but not be output #if defined(__WAVE__) && defined(CREATE_PREPROCESSED_FILES) #pragma wave option(preserve: 2, line: 1, output: "preprocessed/example.hpp") #endif // stuff here will be preprocessed and written to the file // preprocessed/example.hpp (here: relative to example.hpp) #if defined(__WAVE__) && defined(CREATE_PREPROCESSED_FILES) #pragma wave option(output: null) #endif // stuff here will be preprocessed but not be output File: example.cpp // stuff here will be preprocessed but not be output #include "example.hpp" The crucial trick is to invoke the wave driver with the --output=- (short option: -o-) command line option, which starts off with the output suppressed. Having to add -DCREATE_PREPROCESSED_FILES is obvious. Regards Hartmut --------------- http://boost-spirit.com

On Dec 6, 2010, at 7:34 AM, "Hartmut Kaiser" <hartmut.kaiser@gmail.com> wrote:
What everybody is looking for is partial preprocessing, i.e. expansion of only some of the macros. Wave does not directly support this (does any preprocessor?)
Isn't that just a matter of injecting #undefs for the other macros? Perhaps an easy hack to wave… -- BoostPro Computing * http://boostpro.com [Sent from coveted but awkward mobile device]

On Dec 6, 2010, at 7:34 AM, "Hartmut Kaiser" <hartmut.kaiser@gmail.com> wrote:
What everybody is looking for is partial preprocessing, i.e. expansion of only some of the macros. Wave does not directly support this (does any preprocessor?)
Isn't that just a matter of injecting #undefs for the other macros? Perhaps an easy hack to wave…
That won't do it. You want to properly handle #ifdef's (how do you do that with #undef'ed macros?) to keep platform specific code in place. Regards Hartmut --------------- http://boost-spirit.com

At Mon, 6 Dec 2010 07:26:09 -0600, Hartmut Kaiser wrote:
On Dec 6, 2010, at 7:34 AM, "Hartmut Kaiser" <hartmut.kaiser@gmail.com> wrote:
What everybody is looking for is partial preprocessing, i.e. expansion of only some of the macros. Wave does not directly support this (does any preprocessor?)
Isn't that just a matter of injecting #undefs for the other macros? Perhaps an easy hack to wave…
That won't do it. You want to properly handle #ifdef's (how do you do that with #undef'ed macros?) to keep platform specific code in place.
Then "expansion of only some of the macros" doesn't really capture what you mean by "partial preprocessing." Am I missing something? -- Dave Abrahams BoostPro Computing http://www.boostpro.com

At Mon, 6 Dec 2010 07:26:09 -0600, Hartmut Kaiser wrote:
On Dec 6, 2010, at 7:34 AM, "Hartmut Kaiser" <hartmut.kaiser@gmail.com> wrote:
What everybody is looking for is partial preprocessing, i.e. expansion of only some of the macros. Wave does not directly support this (does any preprocessor?)
Isn't that just a matter of injecting #undefs for the other macros? Perhaps an easy hack to wave…
That won't do it. You want to properly handle #ifdef's (how do you do that with #undef'ed macros?) to keep platform specific code in place.
Then "expansion of only some of the macros" doesn't really capture what you mean by "partial preprocessing." Am I missing something?
Well, that's because the suggestion I made is not about expanding a partial subset of all macros, but about generating output only for that part of the input we're interested in (i.e. single header files). I'm sorry if my wording caused confusion. I wrote:
Wave does not directly support this (does any preprocessor?), but what you can do is to use #pragmas to enable/disable output generation. This creates the effect of partially expanding only a subset of the input.
By preprocessing everything as usual, but creating output for only part of the input, you can create the illusion of doing partial preprocessing. IIUC, that's essentially what needs to be accomplished for generating preprocessed headers for Fusion, Proto, etc. Regards Hartmut --------------- http://boost-spirit.com
participants (2)
-
Dave Abrahams
-
Hartmut Kaiser