SerbanLupu
SerbanLupu

Reputation: 437

Can you use a.b notation in a #define macro name?

I want to declare a define, using Visual Studio 2008 or 2010, like that:

#define a.b c.d

and I get following error:

error C2008: '.' : unexpected in macro definition

I see that I am allowed to create a define like this:

#define a c.d

Is the a.b notation supposed to be allowed in the macro name?

Upvotes: 2

Views: 1159

Answers (2)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361412

Macros has same set of rules for naming, as do identifiers. In fact, macro-names are identifiers.

So,

  • They cannot contain dot.
  • They can consist of only alphabet, digits, and underscore. Nothing else. They cannot start with a digit, however.

Upvotes: 13

FelixCQ
FelixCQ

Reputation: 2028

How about doing the follwing instead?

#define a c
#define b d

Upvotes: 3

Related Questions