Anyway, my question is why doesn't __LINE__ expand correctly when used in macros?
For example, the following code should declare a different variable each time
ANONYMOUS_VARIABLE is used:
#define REALLY_CONCATENATE(str1, str2) str1##str2
#define CONCATENATE(str1, str2) REALLY_CONCATENATE(str1, str2)
#define ANONYMOUS_VARIABLE CONCATENATE(anonymous, __LINE__)
//Use it like this:
int ANONYMOUS_VARIABLE; //declares variable named anonymous0
int ANONYMOUS_VARIABLE; //declares variable named anonymous1
It works fine in just any other compiler (gcc and Como to name a few)
But on VC60 (SP5) it fales to expand __LINE__ and instaead of
two variables "anonymous0" and "anonymous1" I get redefinition
of plain "anonymous"
Is there a workaround?
Thank you,
Andy.
I use this everyday:
#define STRINGIZE( L ) #L
#define MAKESTRING( M, L ) M(L)
#define MESSAGE_ORIGIN __FILE__ "(" MAKESTRING( STRINGIZE, __LINE__ ) "): "
#pragma message ( MESSAGE_ORIGIN "QED" )
> Thank you,
> Andy.
Schobi
--
Spam...@gmx.de is never read
I'm Schobi at suespammers org
http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b199057
So am I.
> [...]