Thread overview
[Issue 23936] ImportC: pragma pack is not working for structs
[Issue 23936] ImportC: pragma pack is not working for concrete module (libuv)
May 26, 2023
Walter Bright
May 29, 2023
Walter Bright
May 29, 2023
Walter Bright
May 30, 2023
Walter Bright
May 30, 2023
Dlang Bot
May 30, 2023
Dlang Bot
May 26, 2023
https://issues.dlang.org/show_bug.cgi?id=23936

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ImportC
                 CC|                            |bugzilla@digitalmars.com

--
May 29, 2023
https://issues.dlang.org/show_bug.cgi?id=23936

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
The problem can be duplicated with:

test.d:

  import impc;
  pragma(msg, "M128A.align ", M128A.alignof );
  pragma(msg, "_CONTEXT.align ", _CONTEXT.alignof );
  pragma(msg, "SomeType.align ", SomeType.alignof );

impc.i:

  __pragma(pack(push, 16))
  typedef struct /*garbage*/ {
        long long val;
  } SomeType, *PSomeType;
  __pragma(pack(pop))

  #pragma pack(push,16)
  __pragma(pack(push,16))
  typedef struct /*__declspec(align(16))*/ _M128A {
    long long Low;
    long long High;
  } M128A, *PM128A;
  __pragma(pack(pop))
  #pragma pack(pop)

  #pragma pack(push,16)
  __pragma(pack(push,16))
  typedef struct _CONTEXT {
    int LastExceptionFromRip;
  } CONTEXT, *PCONTEXT; //__attribute__((aligned( 16))), *PCONTEXT;
  __pragma(pack(pop))
  #pragma pack(pop)

compiling:

  M128A.align 8LU
  _CONTEXT.align 4LU
  SomeType.align 16LU

Something seems wrong with __pragma.

--
May 29, 2023
https://issues.dlang.org/show_bug.cgi?id=23936

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Further investigation shows that it works if the struct is anonymous, does not otherwise.

--
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=23936

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
            Summary|ImportC: pragma pack is not |ImportC: pragma pack is not
                   |working for concrete module |working for structs
                   |(libuv)                     |
                 OS|Windows                     |All

--
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=23936

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #15278 "fix Issue 23936 - ImportC: pragma pack is not working for structs" fixing this issue:

- fix Issue 23936 - ImportC: pragma pack is not working for structs

https://github.com/dlang/dmd/pull/15278

--
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=23936

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15278 "fix Issue 23936 - ImportC: pragma pack is not working for structs" was merged into master:

- e696adf37d83ee456680035bc517fb3b8edce293 by Walter Bright:
  fix Issue 23936 - ImportC: pragma pack is not working for structs

https://github.com/dlang/dmd/pull/15278

--