Wouldn't this be better with bitfields?
claptrap
clap at trap.com
Sun Jul 7 10:21:48 UTC 2024
On Friday, 5 July 2024 at 16:48:29 UTC, Walter Bright wrote:
> On 7/3/2024 6:47 PM, Steven Schveighoffer wrote:
>> But... I'm thinking now, why not just specify that? If you use
>> uint, this is the explicit layout, and any C compiler that
>> doesn't implement that mechanism, D does not support bitfield
>> compatibility.
>> That would go a long way to alleviating any concerns that
>> portability would be based on the whim of some C compiler.
>>
>> This should be fine, because, as you say, everyone already
>> does it that way. D has the opportunity to make this official.
>
> AFAIK, no C compiler has bothered to document the details of
> their bit field layout.
>
> As for D, it specifies that the layout will match that of the
> "associated C compiler".
>
> We could add a "best practices" note in the spec.
D should not be adding language features that change their
specification depending on what external C compiler happens to be
attached to the project.
That is a ridiculous design.
You need to detox your brain of C. First it was C functions
should be assumed safe, then it was string interpolation should
be built around printf compatibility, and now it's bitfields
should change their implementation based on whatever C compiler
is attached?
The C part of your brain keeps leading you done one bad path
after another.
More information about the Digitalmars-d
mailing list