Why does it expand to BOOST_VERSION_NUMBER_AVAILABLE?

Open
#128 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp
Domain
compilers

Research direction

Start by tracing how BOOST_OS_UNIX and other Boost.Predef macros expand to BOOST_VERSION_NUMBER_AVAILABLE, then compare that behavior with the shown BOOST_PP_IF use case. Determine whether the intended outcome is separate 1/0 macros such as BOOST_OS_UNIX10 or changing the existing macros, and validate the chosen behavior with relevant preprocessor usage.

Written by the indexing model from the issue text.

Description

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?

Dominant language
C
Stars
56
Forks
87
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/predef

All issues in boostorg/predef

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.