[Preprocessor] Generate #include directive with preprocessor

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?

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

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

On 2/13/2013 6:43 AM, Adam Badura wrote:
Is it possible to use preprocessor to generate #include directives (or in any other way include the files)?
No it is not possible. You cannot define a macro which expands to other another macro definition or any other basic preprocessor construct, including the #include.
participants (4)
-
Adam Badura
-
Edward Diener
-
Paul Mensonides
-
TONGARI