G
gry
[g++ 4.4.0, linux, large SW project so I can't change compilers or the
api I'm talking to]
I have a macro:
#define RegisterFactory(clazz) \
clazz clazz##_instance; \
extern "C" Foo::HHFactory *get##clazz() { return
&clazz##_instance; } \
Foo::HHRegistrar clazz##_registrar(#clazz)
which works fine for literal arguments. But when I give it an
argument that was defined on the compile line:
g++ -DFACTORYNAME=MyFactory
it fails. I understand why... the arg is used in paste and stringify
contexts -- but is there some reasonable way to fix this?
I want
RegisterFactory(FACTORYNAME) to expand to:
MyFactory MyFactory_instance;
extern "C" Foo::HHFactory *getMyFactory() { return
&MyFactory_instance; } \
Foo::HHRegistrar MyFactory_registrar("MyFactory")
The original macro is used in many places so I need something that
cleanly replaces it. I tried #define FACTORYNAME MyFactory, but no
difference(not that I really expected one).
api I'm talking to]
I have a macro:
#define RegisterFactory(clazz) \
clazz clazz##_instance; \
extern "C" Foo::HHFactory *get##clazz() { return
&clazz##_instance; } \
Foo::HHRegistrar clazz##_registrar(#clazz)
which works fine for literal arguments. But when I give it an
argument that was defined on the compile line:
g++ -DFACTORYNAME=MyFactory
it fails. I understand why... the arg is used in paste and stringify
contexts -- but is there some reasonable way to fix this?
I want
RegisterFactory(FACTORYNAME) to expand to:
MyFactory MyFactory_instance;
extern "C" Foo::HHFactory *getMyFactory() { return
&MyFactory_instance; } \
Foo::HHRegistrar MyFactory_registrar("MyFactory")
The original macro is used in many places so I need something that
cleanly replaces it. I tried #define FACTORYNAME MyFactory, but no
difference(not that I really expected one).