[英]Using BOOST_PP_SEQ_FOR_EACH to define macros
In the example in boost's documentation about BOOST_PP_SEQ_FOR_EACH
the show how to use BOOST_PP_SEQ_FOR_EACH
and (w)(x)(y)(z)
to expand to w_ x_ y_ z_
.在 boost 文档中关于
BOOST_PP_SEQ_FOR_EACH
的示例中,展示了如何使用BOOST_PP_SEQ_FOR_EACH
和(w)(x)(y)(z)
扩展为w_ x_ y_ z_
。 http://www.boost.org/doc/libs/1_61_0/libs/preprocessor/doc/ref/seq_for_each.html This is nice but I need it to expand to http://www.boost.org/doc/libs/1_61_0/libs/preprocessor/doc/ref/seq_for_each.html这很好,但我需要它扩展到
#define w _
#define x _
#define y _
#define z _
If I use #define MACRO_DEFINE(r, data, elem) #define elem data
and BOOST_PP_SEQ_FOR_EACH(MACRO_DEFINE, _, SEQ)
I get the following compilation error error: '#' is not followed by a macro parameter
.如果我使用
#define MACRO_DEFINE(r, data, elem) #define elem data
和BOOST_PP_SEQ_FOR_EACH(MACRO_DEFINE, _, SEQ)
我得到以下编译错误error: '#' is not followed by a macro parameter
。 Any idea how to do it?知道怎么做吗?
Any idea how to do it?
知道怎么做吗?
It is not possible to do that.这是不可能的。 It's not possible to define a macro from inside a macro.
无法从宏内部定义宏。 You have to write it out.
你必须把它写出来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.