Skip to content

context::set_language does not correctly set __cplusplus #263

Open

Description

@martis42

I am using wave as library in a tool which preprocesses C++ code to obtain some information and then lint it.
This requires preprocessing the code with a proper value for __cplusplus, as the code might use different #if .. branches depending on the value.

I know the C++ standard of the project. But I can't set __cplusplus myself because it is a special value which wave ignores when using the context::remove_macro_definition or context::add_macro_definition functions. This is fine, since the public API context::set_language exists.

However, I believe this API does not behave as expected:

On the other hand, boost::wave::language_support::support_cpp, boost::wave::language_support::support_cpp11 and boost::wave::language_support::support_cpp20 cause __cplusplus to be set to the expected value.

I believe wave should offer a dedicated boost::wave::language_support::support_cppXX value for each released C++ version and set __cplusplus accordingly for preprocessing according to the values documented here

If you agree with the request I am happy to create a contribution for that.

Activity

  1. jefftrull commented on Sep 26, 2026

    @jefftrull
    Collaborator

    That sounds very reasonable and I would welcome a PR. Thanks!

  2. jefftrull commented on Sep 26, 2026

    @jefftrull
    Collaborator

    Update: the c++14 thing may be challenging, as we would need to separate out the associated features, which are currently lumped either under C++11 or 17, I can't remember which

  3. martis42 commented on Sep 27, 2026

    @martis42
    ContributorAuthor

    Update: the c++14 thing may be challenging, as we would need to separate out the associated features, which are currently lumped either under C++11 or 17, I can't remember which

    I believe The C++14 mode can be with respect to the associated features be a copy of C++11. It seems to me, C++14 simply did not ad new things to the language on preprocessor level. The things wave associates with C++11 and C++17 are correctly associated:

    • Officially supporting files with a missing new-line at the end as added with C++11
    • has_include was added with C++17
  4. jefftrull commented on Sep 28, 2026

    @jefftrull
    Collaborator

    See also #184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions