
On Wed, 13 Feb 2013 23:01:56 +0800, TONGARI wrote:
2013/2/13 Adam Badura
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
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