#pragma pack effect

后端 未结 11 1790
生来不讨喜
生来不讨喜 2020-11-22 03:19

I was wondering if someone could explain to me what the #pragma pack preprocessor statement does, and more importantly, why one would want to use it.

I

11条回答
  •  面向向阳花
    2020-11-22 03:53

    You'd likely only want to use this if you were coding to some hardware (e.g. a memory mapped device) which had strict requirements for register ordering and alignment.

    However, this looks like a pretty blunt tool to achieve that end. A better approach would be to code a mini-driver in assembler and give it a C calling interface rather than fumbling around with this pragma.

提交回复
热议问题