On 10/6/07, Tobias Schwinger <tschwinger@isonews2.com> wrote:
Server Levent Yilmaz wrote:
> Hi all,
>
> Please take a look as this trivial example of file iteration:

[... code]

>
> Perhaps not so obvious many (wasn't to me),  that
>
> #define BOOST_PP_FILENAME_1 __FILE__
>
> doesn't work.

Yes, because it /always/ expands to the current file (also in the file
loaded with #include BOOST_PP_ITERATE()).

> One has to specify (kind of like hardcode) the file's name
> in there.. Is there some, possibly contrived, way to achieve automation
> of this?

     #include <boost/preprocessor/slot/slot.hpp>

     #define MIN 0
     #define MAX 9

     #ifndef RESET_DONE
     #   define BOOST_PP_VALUE MIN
     #   include BOOST_PP_ASSIGN_SLOT(1)
     #   define RESET_DONE
     #endif

     *****
     * BOOST_PP_SLOT(1) *
     *****

     #if BOOST_PP_SLOT(1) < MAX
     #   define BOOST_PP_VALUE BOOST_PP_SLOT(1)+1
     #   include BOOST_PP_ASSIGN_SLOT(1)
     #   include __FILE__
     #else
     #   undef RESET_DONE
     #endif


Please note this code has several limitations, however:

1. The #include __FILE__ part is not handled correctly by all preprocessors.

2. You might want to partially unroll the iteration not to hit internal
limits too easily.


Hey thanks Tobias, I can count on u as usual. I'll try these.. Though hardcoding filename doesn't look so bad now out of a sudden :)
 

> PS: What an AMAZING library this Boost.Preprocessor is!?

See its successor to be SHOCKED :-)

     http://sf.net/projects/chaos-pp


thnx there for the the pointer.. It certainly does look shocking! Though, it isn't exactly user-ready yet is it? How should I go about building the docs? How long has it been around? Why is it chaos, not boost? too many questions, sorry. aborting... 

~levent()