wave: preprocessing Visual C++ 2005 stl
Hello boost wave users,
I have written a sample program which uses boost wave and I am trying to run
it on its own source code. The environnement (especially the stl) is
Microsoft Visual C++ 2005.
Since typically an include file like "vector" will be preprocessed many
times (once for every compilation unit), I am saving all the preprocessed
tokens in a
map
Ludovic Aubert wrote:
I have written a sample program which uses boost wave and I am trying to run it on its own source code. The environnement (especially the stl) is Microsoft Visual C++ 2005. Since typically an include file like "vector" will be preprocessed many times (once for every compilation unit), I am saving all the preprocessed tokens in a map
,string> > token, so that token[path][make_tuple(line,col)] = value. Then for each path I am using a forward iterator to spit out all the values into a buffer. The major trouble I have is with the macros #define STD_BEGIN namespace std { #define STD_END } defined in the file "yvals.h" Somehow, STD_BEGIN and STD_END are replaced by blanks and I get "namespace std{}" at the end of the files instead. Looks like the line and col for these items are wrong ...
The problem is, that all tokens always carry the positional information of the place of their initial occurrence, i.e. tokens from a replacement text of a macro carry the position where they have been defined, and not where they have been inserted in the output.
I would like to know if someone has already successfully preprocessed the stl delivered with Visual C++ 2005.
Sure, this should work. Try to preprocess these headers with the wave driver applet (boost/tools/wave). Regards Hartmut
thank you, that solved this first issue. thank you for your prompt response.
I now want to keep it from skipping withespaces. I haven't figured out how
to do this yet, but I will follow your advice about the driver.
Thanks a lot
Ludovic Aubert
2007/6/7, Hartmut Kaiser
Ludovic Aubert wrote:
I have written a sample program which uses boost wave and I am trying to run it on its own source code. The environnement (especially the stl) is Microsoft Visual C++ 2005. Since typically an include file like "vector" will be preprocessed many times (once for every compilation unit), I am saving all the preprocessed tokens in a map
,string> > token, so that token[path][make_tuple(line,col)] = value. Then for each path I am using a forward iterator to spit out all the values into a buffer. The major trouble I have is with the macros #define STD_BEGIN namespace std { #define STD_END } defined in the file "yvals.h" Somehow, STD_BEGIN and STD_END are replaced by blanks and I get "namespace std{}" at the end of the files instead. Looks like the line and col for these items are wrong ...
The problem is, that all tokens always carry the positional information of the place of their initial occurrence, i.e. tokens from a replacement text of a macro carry the position where they have been defined, and not where they have been inserted in the output.
I would like to know if someone has already successfully preprocessed the stl delivered with Visual C++ 2005.
Sure, this should work. Try to preprocess these headers with the wave driver applet (boost/tools/wave).
Regards Hartmut
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Ludovic Aubert wrote:
thank you, that solved this first issue. thank you for your prompt response. I now want to keep it from skipping withespaces. I haven't figured out how to do this yet, but I will follow your advice about the driver.
You can configure Wave to leave all the whitespace in the generated token stream. This is a bit tricky, though. You'll have to do two things: A) The Wave library itself may be instructed to leave the comments in the generated output token stream using ctx.set_language( boost::wave::enable_preserve_comments( ctx.get_language())); B) You'll have to implement the may_skip_whitespace() pp hook returning 'false' for all tokens. This instructs the Wave library not to remove any whitespace tokens from the generated output. Both options are implemented in the wave driver (search for the --preserve command line option), looking there will reveal all the magic... HTH Regards Hartmut
Hello Harmut, So I am getting a sequence of tokens (line, column, value). As the iteration over tokens progresses, so do the column and line values, as expected from left to right and top to bottom. But if a macro like STD_BEGIN is encontered, the replacement (ie "namespace std {") will bear the column and line values from the location where it is defined. My goal is to insert '\n' characters in order to reconstruct the original line numbering in the output buffer. The macro in this exemple makes it very difficult or is there any way to do this in a simple way ? Thank you in advance if you can help Ludovic Aubert
Ludovic Aubert wrote:
So I am getting a sequence of tokens (line, column, value). As the iteration over tokens progresses, so do the column and line values, as expected from left to right and top to bottom. But if a macro like STD_BEGIN is encontered, the replacement (ie "namespace std {") will bear the column and line values from the location where it is defined. My goal is to insert '\n' characters in order to reconstruct the original line numbering in the output buffer. The macro in this exemple makes it very difficult or is there any way to do this in a simple way ?
There is an example in Wave (at least in Boost CVS::HEAD) called 'real_positions' doing just what you want. It uses the generated_token() preprocessing hook to keep track of the actual token position and stores this position inside the token (this example uses a special token type carrying both, the original and the actual position. Please note that this pp hook has been added recently only and it is not yet available in Boost 1.34. HTH Regards Hartmut
participants (2)
-
Hartmut Kaiser
-
Ludovic Aubert