C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Achieving pragma pack(1) with typedef<unaligned>

From: Alejandro Colomar <une+cxx_std-proposals_at_[hidden]>
Date: Mon, 8 Jun 2026 14:50:18 +0200
Hi Frederick,

On 2026-06-08T13:21:27+0100, Frederick Virchanza Gotham via Std-Proposals wrote:
> On Mon, Jun 8, 2026 at 1:11 AM Alejandro Colomar wrote:
> >
> > Also, keeping a struct K that is not packed is going to be error prone.
> > One might use struct J thinking it's also packed.
>
>
> struct K_unpacked { . . . };
>
> typedef< std::unaligned > K_unpacked K;

I still don't see why you'd want to keep a struct that you don't want.

It might make more sense as

 typedef<std::unaligned> struct {...} K;

But needing typedef to make a structure unaligned seems to be
a workaround. I'd rather make it a type specifier _Packed, or an
unignorable attribute such as [[::packed]]. We also need this in C,
FWIW.

> > Have a lovely night!
>
>
> It's a little after noon where I am.

Have a lovely night when it arrives! :)
Alex

-- 
<https://www.alejandro-colomar.es>

Received on 2026-06-08 12:50:25