August 31, 2021

On Monday, 30 August 2021 at 22:45:36 UTC, TheGag96 wrote:

>

On Saturday, 28 August 2021 at 08:20:25 UTC, Walter Bright wrote:

>
  1. DasBetterC is not in a great place since it can't do matching bit fields.

I think I may be experiencing a bug in a betterC project of mine as a result of me assuming that bitfields is doing the same thing as gcc would...! Is there a way I can get things synced up on at least one platform in the meantime?

Don't use bitfields for anything that needs to have a stable ABI. They're not even guaranteed to have the same layout when using the same compiler on different platforms [1], much less between different languages.

[1] https://yarchive.net/comp/linux/bitfields.html

August 31, 2021

On Tuesday, 31 August 2021 at 01:04:57 UTC, Paul Backus wrote:

>

On Monday, 30 August 2021 at 22:45:36 UTC, TheGag96 wrote:

>

On Saturday, 28 August 2021 at 08:20:25 UTC, Walter Bright wrote:

>
  1. DasBetterC is not in a great place since it can't do matching bit fields.

I think I may be experiencing a bug in a betterC project of mine as a result of me assuming that bitfields is doing the same thing as gcc would...! Is there a way I can get things synced up on at least one platform in the meantime?

Don't use bitfields for anything that needs to have a stable ABI. They're not even guaranteed to have the same layout when using the same compiler on different platforms [1], much less between different languages.

[1] https://yarchive.net/comp/linux/bitfields.html

I'm working on a single, very specific platform, and the library I'm interfacing with was the one who chose to make data structures that had bitfields, not me.

August 31, 2021

On Tuesday, 31 August 2021 at 01:04:57 UTC, Paul Backus wrote:

>

On Monday, 30 August 2021 at 22:45:36 UTC, TheGag96 wrote:

>

On Saturday, 28 August 2021 at 08:20:25 UTC, Walter Bright wrote:

>
  1. DasBetterC is not in a great place since it can't do matching bit fields.

I think I may be experiencing a bug in a betterC project of mine as a result of me assuming that bitfields is doing the same thing as gcc would...! Is there a way I can get things synced up on at least one platform in the meantime?

Don't use bitfields for anything that needs to have a stable ABI. They're not even guaranteed to have the same layout when using the same compiler on different platforms [1], much less between different languages.

[1] https://yarchive.net/comp/linux/bitfields.html

Then maybe introduce a bitfields with a keyword indicating that it's not cross platform?

__bitfields bool a:1, b:1, c:1, d:1;

August 31, 2021
On 8/30/2021 12:40 PM, Paul Backus wrote:
> On Monday, 30 August 2021 at 18:39:20 UTC, Walter Bright wrote:
>> On 8/29/2021 11:32 PM, Elronnd wrote:
>>> On Saturday, 28 August 2021 at 08:20:25 UTC, Walter Bright wrote:
>>>> how gcc/clang do it is essentially undocumented
>>>
>>> x86-64-psABI, sec 3.1.2 (data representation)
>>
>> https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf
>>
>> That only partially documents it. It doesn't cover things like alignment and 0 length fields.
> 
> Zero-length bitfields are covered by the C standard:
> 
>> As a special case, a bit-field structure member with a width of 0 indicates that no further bit-field is to be packed into the unit in which the previous bit-field, if any, was placed.
> 
> Source: http://port70.net/~nsz/c/c99/n1256.html#6.7.2.1p11

Doesn't cover alignment, either. Doesn't cover what happens with a struct where the only member is a 0 bit field. Doesn't cover what a sequence of 2 or more 0 bit fields does.
August 31, 2021
On 8/30/2021 3:45 PM, TheGag96 wrote:
> I think I may be experiencing a bug in a betterC project of mine as a result of me assuming that `bitfields` is doing the same thing as gcc would...! Is there a way I can get things synced up on at least one platform in the meantime?

The ImportC bit fields will be in the next dmd beta.

Until D itself gets bit fields, the thing to do will be to declare the bit field struct in a separate .c file, and import it.

Otherwise, the only way is to implement your own using get/set member functions.
August 31, 2021
On 8/30/2021 6:04 PM, Paul Backus wrote:
> Don't use bitfields for anything that needs to have a stable ABI. They're not even guaranteed to have the same layout when using the same compiler on different platforms [1], much less between different languages.

Things are pretty consistent if sticking with simple int/unsigned bit fields.
1 2 3
Next ›   Last »