philnik777 wrote:

> > Wouldn't it be better to go the other way around? i.e. have a 
> > `[[clang::compressed_bitfield]]` (or whatever) which influences the ABI, so 
> > it's possible to do stuff like
> > ```
> > [[clang::compressed_bitfield]] bool IsSomething : 1;
> > [[clang::compressed_bitfield]] MyEnum Whatever : 3;
> > [[clang::compressed_bitfield]] int MoreStuff : 4;
> > ```
> > 
> > 
> > which the current approach doesn't allow.
> 
> The issue is that MSVC wouldn't know/recognize/implement this attribute - so 
> clang couldn't do that without breaking ABI compatibility with MSVC.

That's not important for everybody, and you could still `#if` around that code 
like
```c++
#if __has_cpp_attribute(clang::compressed_bitfield)
#define BITFILED_T(ActualType, ABIType) 
static_assert(check_abi_compat<ActualType, ABIType>()); 
[[clang::compressed_bitfield]] ActualType
#else
#define BITFIELD_T(ActualType, ABIType) ABIType
...
```
Sure, it's not super pretty, but it gets you there and allows you to do more 
stuff. We could also ask the MSVC folks whether there would be interest to add 
such an attribute, since there is clearly interest in having a good ABI and 
stronger typing (CC @StephanTLavavej @CaseyCarter).

https://github.com/llvm/llvm-project/pull/69104
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to