Skip to content

context::set_language does not correctly set __cplusplus #263

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:

  • boost::wave::language_support::support_cpp14 does not exists, thus one cannot set __cplusplus accordingly
  • boost::wave::language_support::support_cpp17 sets __cplusplus to 199711L, aka C++98
  • boost::wave::language_support::support_cpp23 sets __cplusplus to 199711L, aka C++98
  • boost::wave::language_support::support_cpp14 boost::wave::language_support::support_cpp26 does not exists, thus one cannot set __cplusplus accordingly. To be fair, C++26 is quite new and this point is more for completeness sake.

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

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