Boost logo

Boost Users :

Subject: Re: [Boost-users] [Preprocessor] Generate #include directive with preprocessor
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2013-02-20 00:46:04


On Wed, 13 Feb 2013 23:01:56 +0800, TONGARI wrote:

> 2013/2/13 Adam Badura <abadura_at_[hidden]>
>
>> Is it possible to use preprocessor to generate #include directives (or
>> in any other way include the files)?
>>
>> For example if I would have a sequence of strings (being file paths)
>> what to do to include all those files? It is possible at all?
>>
>>
> I guess, if it's possible, it may look like: #define
> INCLUDE_FILES(prefix, (f1)(f2)..., postfix) #include <include_files.hpp>

At one point I implemented something that did a Bash-like expansion on the
filenames (i.e. {a,b}{c,d} -> ab ad bc bd except with a different syntax).

That aside, if you do something like

#define FILES (a.h)(b.h)(c.h)
#include INCLUDE_FILES()

The problem is recursion. What happens when (e.g.) a.h attempts to use
FILES? With file-iteration (and I don't remember if Boost.Preprocessor
does this offhand, but Chaos does), only one filename is being iterated
which can be stored in __FILE__ and recovered later (since it is sort of
push/popped by the preprocessor as files are "executed").

Regards,
Paul Mensonides


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net