I create a main.cpp in my vscode with clangd enabled, and put the following code in it.
clangd warns the first line with the warning message:
warning: unterminated ‘#pragma pack (push, …)’ at end of file
The whole content of main.cpp:
#pragma pack(push) // warning on this line
#pragma pack(1)
struct A
{
int a;
short b;
char c;
};
#pragma pack(pop)
See also: https://releases.llvm.org/13.0.0/tools/clang/docs/DiagnosticsReference.html#wpragma-pack
I think it's a very common usage of #pragma pack(push)
, I don't understand why the warning is generated.
More strange to me, if I add a semicolon before the first line, the warning disappears.
; // Add a semicolon
#pragma pack(push) // The warning disappears
#pragma pack(1)
struct A
{
int a;
short b;
char c;
};
#pragma pack(pop)
What's the reason behind?