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

送分小仙女□ 提交于 2021-01-28 04:28:41

问题


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?


回答1:


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.



回答2:


How about doing the follwing instead?

#define a c
#define b d


来源:https://stackoverflow.com/questions/8040391/can-you-use-a-b-notation-in-a-define-macro-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!