Date: Sun, 10 Dec 2023 00:20:03 +0000
On Sat, 2023-12-09 at 22:14 +0000, Frederick Virchanza Gotham via Std-
Proposals wrote:
>
> On Saturday, December 9, 2023, Frederick Virchanza Gotham wrote:
> >
> > In both of these use cases, I'd much prefer if we could do the
> > following:
> >
> > struct TokenInfo {
> > long unsigned a;
> > char b;
> > long unsigned c;
> > char d;
> > };
> >
> > typedef struct TokenInfo [[packed]] TicketInfo;
> >
> > So now 'TicketInfo' is a packed form of the 'TokenInfo' struct.
> >
>
>
> Actually let me go a bit further with this. When you have:
>
> struct TokenInfo {
> long unsigned a;
> char b;
> long unsigned c;
> char d;
> };
>
> typedef struct TokenInfo [[packed]] TicketInfo;
>
> The compiler treats it as if you had written:
>
> struct TokenInfo {
> long unsigned a;
> char b;
> long unsigned c;
> char d;
> };
>
> struct TicketInfo {
> unaligned<long unsigned> a;
> unaligned<char> b;
> unaligned<long unsigned> c;
> unaligned<char> d;
> };
>
An attribute is the wrong tool for this as it is ignorable. Maybe once
metaclasses land then it could be feasible, and still a pure library
implementation.
Proposals wrote:
>
> On Saturday, December 9, 2023, Frederick Virchanza Gotham wrote:
> >
> > In both of these use cases, I'd much prefer if we could do the
> > following:
> >
> > struct TokenInfo {
> > long unsigned a;
> > char b;
> > long unsigned c;
> > char d;
> > };
> >
> > typedef struct TokenInfo [[packed]] TicketInfo;
> >
> > So now 'TicketInfo' is a packed form of the 'TokenInfo' struct.
> >
>
>
> Actually let me go a bit further with this. When you have:
>
> struct TokenInfo {
> long unsigned a;
> char b;
> long unsigned c;
> char d;
> };
>
> typedef struct TokenInfo [[packed]] TicketInfo;
>
> The compiler treats it as if you had written:
>
> struct TokenInfo {
> long unsigned a;
> char b;
> long unsigned c;
> char d;
> };
>
> struct TicketInfo {
> unaligned<long unsigned> a;
> unaligned<char> b;
> unaligned<long unsigned> c;
> unaligned<char> d;
> };
>
An attribute is the wrong tool for this as it is ignorable. Maybe once
metaclasses land then it could be feasible, and still a pure library
implementation.
Received on 2023-12-10 00:20:12