Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does it expand to BOOST_VERSION_NUMBER_AVAILABLE? #128

Open
vinipsmaker opened this issue Mar 25, 2023 · 2 comments
Open

Why does it expand to BOOST_VERSION_NUMBER_AVAILABLE? #128

vinipsmaker opened this issue Mar 25, 2023 · 2 comments

Comments

@vinipsmaker
Copy link

Boost.Predef macros (e.g. BOOST_OS_WINDOWS) expand to BOOST_VERSION_NUMBER_AVAILABLE instead of 1 or 0. Why is that?

By expanding to BOOST_VERSION_NUMBER_AVAILABLE I can't use these macros in Boost.PP. For instance, I recently had to use code like:

BOOST_PP_IF(
    BOOST_OS_UNIX,
    lua_pushcfunction(L, tcp_socket_assign),
    lua_pushcfunction(L, throw_enosys));

But it failed to compile because BOOST_OS_UNIX doesn't expand to 1 or 0. Instead, it expands to a complex expression that can't be used in preprocessor metaprogramming.

Could we offer BOOST_OS_UNIX10 (and the equivalent to other macros as well) that expand to 1 or 0 instead of a complex expression? Or, alternatively, modify these macros to expand to 1 or 0 already?

@grafikrobot
Copy link
Member

Does using BOOST_OS_UNIX() or BOOST_PP_EXPAND(BOOST_OS_UNIX) work?

@vinipsmaker
Copy link
Author

vinipsmaker commented Mar 26, 2023

Does using BOOST_OS_UNIX() or BOOST_PP_EXPAND(BOOST_OS_UNIX) work?

No.

The output for BOOST_PP_IF(BOOST_PP_EXPAND(BOOST_OS_UNIX), a, b) is:

BOOST_PP_IIF_BOOST_PP_BOOL_BOOST_PP_EXPAND(( (((0)%100)*10000000) + (((0)%100)*100000) + ((1)%100000) ))(a, b)

If BOOST_PP_IF(BOOST_PP_EXPAND(BOOST_OS_UNIX), a, b) is given as input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants