
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Suman Cherukuri
I'm using general 'C' compiler in this project (hence I cannot use boost headers). I want to write a macro as follows;
#define ERR(x, y) \ { \ # ifndef ERR##x \ # define ERR##x \ # else \ # error ERR##x already defined\ # endif y = x; \ }
As mentioned by Graeme, macros cannot expand to preprocessing directives. Or, more precisely, they cannot expand to anything that will be _interpreted_ as preprocessing directives. In the above, because it is a function-like macro, the # token acts as a stringizing operator. However, applying the stringizing operator to anything but a formal argument is ill-formed. Regards, Paul Mensonides