Boost.preprocessor : BOOST_PP_EQUAL not working

Boost.preprocessor : BOOST_PP_EQUAL not working

本文关键字:EQUAL not working PP Boost BOOST preprocessor      更新时间:2023-10-16

你好,我对C中的Boost.Preprocessor有问题。我相信C++和C宏的行为完全相同,所以使用Boost。预处理器在C中很好,无论如何,我打算做一个小型的完全预处理器库。我的问题是我不能用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: %dn",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)

我的代码出了什么问题?提前感谢!

EDIT:这是使用-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传递给编译器。