c++ - Boost.预处理器: BOOST_PP_EQUAL not working

标签 c++ c boost c-preprocessor boost-preprocessor

您好,我在 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/

相关文章:

c++ - 使用类的 vector

c++ - 在 Platformio 上使用串行监视器不显示 tty.usbmodem

c - 同名输入/输出问题

c - Compiler 是否优化了由 "malloc()"函数分配的内存?

c++ - 在类 : scoped_ptr or shared_ptr? 中将智能指针作为参数传递

C++:使用回调机制调用函数

c++ - 如何从 extern "C"函数访问类变量?

c++ - 模板矩阵-矩阵乘法c++

c - 无法理解我的 C 程序的正确输出

c++ - 如何交换 mpl::vector 的两个元素?