|Hi Kevin,

thanks for that hint. I already added a
|

|  __attribute__((gcc_struct)) __attribute__((packed))
|

|what looks awkward. But since the attributes can be combined in one
clause, it looks better. I also added
|

|  _Static_assert(sizeof(sample_config_t) == 16, "incompatible layout of
sample_config_t");|

||

|for all structs that define an USB transfer layout (with the
correspoding type name). I think it would be good to have such
compile-time checks that would help revealing differences between our
assumptions and the compiler or configuration reality.

The configuration based on the autotools output already includes the
-mno-ms-bitfield flag, although I couldn't identify how and why this in
the configure result. But with the __attribute__ it's not important anymore.

BTW: The Microsoft compiler doesn't support the __attribute__ at all.
Instead you have to use
|

| #pragma pack(1)|

||

|before the struct definition. I don't understand what problem the
-m(no)-ms-bitfield tries to address. The syntax to control packing is
different anyway.|

||

|
Best regards,
Helge|
|
|

Am 03.01.2021 um 14:33 schrieb Kevin Grant:
>
> Nice find Helge! The gcc_struct attribute might also do it.||
>
> |typedef struct sample_config {
> uint32_t sample_depth;
> uint32_t psa;
> uint16_t u1;
> uint32_t u2;
> uint16_t clock_divisor;
> } __attribute__((gcc_struct, packed)) sample_config_t;|
>
> Rgds
>
> Kevin||
>
> On 2021-01-02 22:51, Ray Molenkamp wrote:
>
>> I do not have the hardware to test on, but with a "hello world" style
>> program -mno-ms-bitfield fixes the struct size from 18 back to 16
>>
>> --Ray
>>
>> On 2021-01-02 11:19 a.m., Paul Fertser wrote:
>>> Hi Helge,
>>>
>>> On Sat, Jan 02, 2021 at 06:20:54PM +0100, Helge Kruse wrote:
>>>> The MXE compiler, that is used for compiling the Windows version
>>>> ignores
>>>> silently this attribute. This can be verified by a simple "Hello,
>>>> World"
>>>> style program.
>>> This is a perfect find! Have you tried compiling with -mno-ms-bitfield
>>> or with pragma pack?
>>>
>>
>>
>> _______________________________________________
>> sigrok-devel mailing list
>> sigrok-devel@lists.sourceforge.net
>> <mailto:sigrok-devel@lists.sourceforge.net>
>> https://lists.sourceforge.net/lists/listinfo/sigrok-devel
>> <https://lists.sourceforge.net/lists/listinfo/sigrok-devel>
>
>
>
>
> _______________________________________________
> sigrok-devel mailing list
> sigrok-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sigrok-devel


_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to