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

Support C++20 feature testing #108

Open
jefftrull opened this issue Aug 5, 2020 · 2 comments
Open

Support C++20 feature testing #108

jefftrull opened this issue Aug 5, 2020 · 2 comments

Comments

@jefftrull
Copy link
Collaborator

C++20 introduces a special predefined macro __has_cpp_attribute() along with a set of predefined language feature macros, all described here. I think that at minimum __has_cpp_attribute() should be defined in C++20 mode, even if it always evaluates to true.

What's less clear to me is whether, and how, the return values should be user-programmable (e.g. for emulating a specific compiler version).

@hkaiser
Copy link
Collaborator

hkaiser commented Aug 5, 2020

I'm not sure if this is something to be supported by Wave. There are arguments both ways.

On one hand, the output Wave produces should be consumable by any other compiler. And that compiler should be able to handle the feature macros depending on its own implementations. For this it might be better to leave the feature macros that identify compiler (i.e. language) features alone and pass them through to the output untouched.

On the other hand, feature macros that are explicitly defined by the standard library or the compiler could be handled by Wave as any other macro, which would require for __has_cpp_attribute() to be recognized by Wave in order to properly resolve preprocessor conditional expressions.

In the end, in order to achieve accurate preprocessing, the process would have to be targetable to a particular platform and/or compiler (in the same way as necessary for code that is referring to predefined macros like __clang__ and similar). This would require to be able to predefine those language attribute-tokens (like carries_dependency) through the command line.

@jefftrull
Copy link
Collaborator Author

What if there was a separate mechanism, via an API on the Context object, for adding attributes? Something similar to add_macro_definition - a separate table for use by __has_cpp_attribute that would allow people to emulate specific compilers...

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