A
Ark Khasin
Due to a peculiar need (code instrumentation) I came across unexpected
behavior of Visual Studio 6.0 and 2005 (doing the same thing):
#include <stdio.h>
#define CAT1(a,b) a ## b
#define CAT(a,b) CAT1(a,b)
#define MYNUM(n) CAT(n,__LINE__)
const int x = MYNUM(35); //OK
int z=MYNUM(78); //OK
int main(int argc)
{
static int y=MYNUM(21); //error!
//6.0: error C2064: term doesn't evaluate to a function
//2005 adds: taking 26451848 arguments.
printf("%d %d\n", x, y );
return 0;
}
Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
preprocessor is the same).
No problem with another compiler (IAR for ARM)...
[Microsoft claims strict standard compliance in the C++ department]
Any suggestions?
Thank you,
Ark
behavior of Visual Studio 6.0 and 2005 (doing the same thing):
#include <stdio.h>
#define CAT1(a,b) a ## b
#define CAT(a,b) CAT1(a,b)
#define MYNUM(n) CAT(n,__LINE__)
const int x = MYNUM(35); //OK
int z=MYNUM(78); //OK
int main(int argc)
{
static int y=MYNUM(21); //error!
//6.0: error C2064: term doesn't evaluate to a function
//2005 adds: taking 26451848 arguments.
printf("%d %d\n", x, y );
return 0;
}
Doesn't matter if I compile as C or as C++ (if I am not mistaken, the
preprocessor is the same).
No problem with another compiler (IAR for ARM)...
[Microsoft claims strict standard compliance in the C++ department]
Any suggestions?
Thank you,
Ark