jhendrix
asked on
#define, #include inside a MACRO
Is there a way to put a #define or a #include inside a MACRO ?
e.g.
#define MY_MACRO(a) \
#define MY_CONSTANT_##a
#define MY_MACRO2(a) \
#include #a
I know that these macros can't compile but I would like a way to make such macros.
e.g.
#define MY_MACRO(a) \
#define MY_CONSTANT_##a
#define MY_MACRO2(a) \
#include #a
I know that these macros can't compile but I would like a way to make such macros.
No, you can't.
See Chapter 16 of the C++ FIDS.
The closest you can come is the use of the #include directive with a macro instead of a string name.
#define MYFILE "foo.h"
#include MYFILE
You can generate a macro for the include directive, too:
#define str(s) # s
#define xstr(s) str(s)
#define INCFILE(n) vers ## n
#include xstr(INCFILE(2).h)
B ekiM
See Chapter 16 of the C++ FIDS.
The closest you can come is the use of the #include directive with a macro instead of a string name.
#define MYFILE "foo.h"
#include MYFILE
You can generate a macro for the include directive, too:
#define str(s) # s
#define xstr(s) str(s)
#define INCFILE(n) vers ## n
#include xstr(INCFILE(2).h)
B ekiM
ASKER
I guess you've actually answered the question ("No I can't") but I really need a way to do this.
As for generating a macro for the include directive, that doesn't help me at all and is pretty basic macro stuff.
Thanx anyways.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good luck with your project.
B ekiM
B ekiM
ASKER
Thanx PAYN,
I appreciate the time you took to answer my question.
I won't be doing all that stuff though, cause the goal is not worth the effort.
But thanx again
jhendrix
I appreciate the time you took to answer my question.
I won't be doing all that stuff though, cause the goal is not worth the effort.
But thanx again
jhendrix
ASKER