$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [preprocessor] ifdef equivalent inside a macro, is it possible?
From: damien benoist (damien_benoist_at_[hidden])
Date: 2011-08-10 09:15:50
Hi all,
Would there be a way to do some "ifdef" inside a macro?
Could be in the form of a macro taking 3 args,
- 1st being the macro to test the existance of,
- 2nd being the value to expand in case 1st arg is a defined macro
- 3rd being the value to expand in case 1st arg is not a defined macro
Exemple:
#define DUMMY_MACRO1 foo1
// next is commented out and not defined
// #define DUMMY_MACRO2 foo2
PP_IFDEF(DUMMY_MACRO1, DUMMY_MACRO1, bar1)
// would expand to foo1
PP_IFDEF(DUMMY_MACRO2, DUMMY_MACRO2, bar2)
// would expand to bar2
Seems impossible to me, but boost/preprocessor
does so many things that seemed impossible to me.
Maybe someone will have some more magic...
Thanks.
Damien.