您好,我在 C 语言中使用 Boost.Preprocessor 时遇到问题。我相信 C++ 和 C 宏的行为完全相同,因此在 C 语言中使用 Boost.Preprocessor 没问题,无论如何我打算做一个小型的完全预处理器库。我的问题是我无法使用 BOOST_PP_EQUAL
编译一个小程序。以下是您可以构建的示例代码:
#include <stdlib.h>
#include <stdio.h>
#include <boost/preprocessor.hpp>
#define TUPLE (0,1,2)
#define IS_NON_ZERO(NODE) BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(NODE),0)
int main(void)
{
int x;
x = IS_NON_ZERO(TUPLE);
printf("result: %d\n",x);
return EXIT_SUCCESS;
}
我正在使用 clang 和 gcc,它们都告诉我宏 BOOST_PP_NOT_EQUALS 不存在!
tiny.c:6:27: error: ‘BOOST_PP_NOT_EQUAL_0’ undeclared (first use in this function)
我的代码有什么问题吗?提前致谢!
编辑:这是使用 -E
标志的非宏行。
x = BOOST_PP_COMPL_BOOST_PP_NOT_EQUAL_CHECK_BOOST_PP_NOT_EQUAL_BOOST_PP_TUPLE_SIZE((0,1,2))(0, BOOST_PP_NOT_EQUAL_0);
到底是什么?
最佳答案
将 -DBOOST_PP_VARIADICS=1
传递给您的编译器。
关于c++ - Boost.预处理器: BOOST_PP_EQUAL not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23547534/