C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [Draft Proposal] Required attribute syntax

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Sat, 6 May 2023 13:33:13 +0200
sob., 6 maj 2023 o 01:25 Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
> On Friday, 5 May 2023 08:33:51 PDT Marcin Jaczewski via Std-Proposals wrote:
> > And if some else grab by headers and try link
> > to my dll I would prefer hard error if compiler do not support NUA or
> > interpret it
> > diffrent than my compiler.
>
> What's the problem with:
>
> #if !__has_cpp_attribute(no_unique_address)
> # error "Data layout would mismatch without [[no_unique_address]]; " \
> "please upgrade your compiler"
> #endif
>

https://gcc.godbolt.org/z/Gxqs6v331
Interesting old MSVC reconginse this attribute but fails on assertion, new one
will say that it does not recognize this attribute.

If we `__has_cpp_attribute` interpreted as "I implement this attribute
functionality", then yes, we could use this macro.
But if it means "I know that attribute exists" like older MSVS did,
then we could not use it.

https://eel.is/c++draft/cpp.cond#:__has_cpp_attribute
"""
Each has-attribute-expression is replaced by a non-zero pp-number
matching the form of an integer-literal if the implementation supports
an attribute with the name specified by interpreting the pp-tokens,
after macro expansion, as an attribute-token, and by 0 otherwise.
The program is ill-formed if the pp-tokens do not match the form of an
attribute-token.
"""

https://en.cppreference.com/w/cpp/feature_test
"""
Checks for the presence of an attribute named by attribute-token
(after macro expansion).
"""

It seems that standard text means "I implement this attribute
functionality" where en.cppreference quote is more ambiguous.


> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-05-06 11:33:24