首页 > 代码库 > C++预定义宏
C++预定义宏
C/C++宏体中出现的#,#@,##:
- #的功能是将其后面的宏参数进行字符串化操作(stringfication),就是对它所引用的宏变量通过替换后在其左右各加上一个双引号
-##被称为连接符(concatenator),用来将两个token连接为一个token。注意这里连接的对象是token就行,而不一定是宏的变量。
举例:
Caffe中Layer的创建:
#define REGISTER_LAYER_CREATOR(type, creator) \ static LayerRegisterer<float> g_creator_f_##type(#type, creator<float>); \ static LayerRegisterer<double> g_creator_d_##type(#type, creator<double>) \
http://blog.csdn.net/langb2014/article/details/50991315
Tips:
如果串长于一行,可以在该行末尾用一反斜杠‘ /‘续行。
http://blog.csdn.net/blaider/article/details/7578141
C++预定义宏
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。