llvm-mingw
llvm-mingw copied to clipboard
warnings when including pshpack?.h or poppack.h
Clang warns when a header modifies the packing pragma, even when that's the purpose of the header.
meh@vincent:~/work/wine-mono$ cat test.c
#include <pshpack1.h>
struct test {
char a;
int b;
};
#include <poppack.h>
int main()
{
return 0;
}
meh@vincent:~/work/wine-mono$ ~/work/wine-pedeps/llvm-mingw-20191230-ubuntu-16.04/bin/i686-w64-mingw32-gcc test.c
test.c:2:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
#include <pshpack1.h>
^
/home/meh/work/wine-pedeps/llvm-mingw-20191230-ubuntu-16.04/i686-w64-mingw32/include/pshpack1.h:7:9: note: previous '#pragma pack' directive that modifies alignment is here
#pragma pack(push,1)
^
test.c:7:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
#include <poppack.h>
^
note: previous '#pragma pack' directive that modifies alignment is here
2 warnings generated.
Yes, this is rather annoying.
I'm not aware of a really good workaround for it. In wine, configure checks whether the compiler supports -Wpragma-pack, and adds -Wno-pragma-pack if it happened to be supported.
The warning in itself is useful in principle, except for these particular headers where it's intentional. And it's (IIRC) hard to disable the warning within the header itself with e.g. a pragma region within the header, since the warning isn't triggered within the header, but when leaving it.
Or would it maybe make sense with something like
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpragma-pack"
in pshpack*.h and
#pragma clang diagnostic pop
in poppack.h? Although I think that might not be enough; it would fix it for the case when returning from pshpack*.h, but not when returning from poppack.h.