Question

Hello I have a problem with Boost.Preprocessor in C. I believe C++ and C macro behaves exactly the same so using Boost.Preprocessor is fine in C and anyway I intend to do a small fully preprocessor library. My issui is that I cannot compile a tiny program using BOOST_PP_EQUAL. Here is the sample code you can build:

#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;
}

I'm using clang and gcc and both told me that the macro BOOST_PP_NOT_EQUALS does not exist!

tiny.c:6:27: error: ‘BOOST_PP_NOT_EQUAL_0’ undeclared (first use in this function)

What is wrong with my code ? Thanks in advance !

EDIT: Here is the non-macro line using the -E flag.

 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);

What the heck ?

Was it helpful?

Solution

Pass -DBOOST_PP_VARIADICS=1 to your compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top