如何在C ++中显示当前的#pragma pack设置?

Blu*_*une 3 c++ compiler-warnings

这是一个如何设置当前#pragma包的示例:

#pragma pack(4)
Run Code Online (Sandbox Code Playgroud)

如何显示当前的#pragma pack设置?

Bat*_*eba 6

With Microsoft's C++ compiler you can use

#pragma pack(show)
Run Code Online (Sandbox Code Playgroud)

which causes the compiler to issue a warning containing the value.

Note this is not standard C++ (and neither is any guise of #pragma pack) so other compilers may or may not have this feature. At the time of writing GCC, for example, doesn't.