I am using G++ 4.5 on OpenSUSE 11.3, and I have a macro defined as follows:
it is specifically intended to be used inside a function in which a client object called cli is accepted as a parameter.Code:template<class destT> destT GetSiteSetting(client& cli, const destT&, const std::string& name) { try { return boost::lexical_cast<destT>(cli.GetSiteRef()[name]); } catch (boost::bad_lexical_cast& ex) { return destT(); } } #define GET_SITE_SETTING(TYPE, NAME) TYPE NAME = GetSiteSetting(cli, TYPE(), #NAME)
the trouble comes in when the type I use contains spaces, such as "unsigned long"
even when I do a typedef as follows:
and then try to use the macro like so:Code:typedef long long LONG;
is C++ supposed to produce this sort of behavior? I would expect that the compiler would recognize the first parameter as a valid type name, regardless of the fact that it contains spaces. I realize that G++ defines things like int64_t, but not all compilers do, and I'd like to keep it portable.Code:GET_SITE_SETTING(LONG, foo);



LinkBack URL
About LinkBacks



