dmd/compiler/test/compilable/test21271.c
drpriver 856d4921a0 Fix #21271 - ImportC: incorrect compatibility macro for __pragma
Fixes https://github.com/dlang/dmd/issues/21271

Redefine the compatibility macro in terms of C99's `_Pragma()`
instead of ignoring it. Clang and GCC will replace `_Pragma()`
with `#pragma` directives in the preprocessed output, while
cl.exe will actually convert it back to `__pragma()`.

This is still a better situation than before as ImportC partially
supports `__pragma()`.
2025-04-19 18:37:13 +08:00

16 lines
336 B
C

// https://github.com/dlang/dmd/issues/21271
#define PUSH __pragma(pack(push))
#define PACK __pragma(pack(1))
#define POP __pragma(pack(pop))
PUSH
PACK
struct S21271_1 {
int x;
};
_Static_assert(_Alignof(struct S21271_1)==1, "1");
POP
struct S21271_2 {
int x;
};
_Static_assert(_Alignof(struct S21271_2)==_Alignof(int), "2");