interview icon indicating copy to clipboard operation
interview copied to clipboard

#pragma pack(n) 应该强调是编译器扩展

Open Mq-b opened this issue 2 years ago • 2 comments

它并非标准的,一般情况下不该去使用它。 可使用标准的 alignasalignof 运算符。

Mq-b avatar Oct 13 '23 01:10 Mq-b

虽然但是, #pragma pack(n)alignas 的功能不同。

对于需要更改对齐的情况,相对于原生对齐 #pragma pack 只会改小对齐,而 alignas 只会改大对齐。

frederick-vs-ja avatar Oct 15 '23 02:10 frederick-vs-ja

的确如此。

Mq-b avatar Oct 18 '23 01:10 Mq-b