dmd icon indicating copy to clipboard operation
dmd copied to clipboard

ImportC: `sizeof` not supported inside ` __attribute__((aligned(...))`

Open pinver opened this issue 1 month ago • 3 comments

In one of ZeroMQ header there's this definition:

typedef struct zmq_msg_t
{
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
    __declspec(align (8)) unsigned char _[64];
#elif defined(_MSC_VER)                                                        \
  && (defined(_M_IX86) || defined(_M_ARM_ARMV7VE) || defined(_M_ARM))
    __declspec(align (4)) unsigned char _[64];
#elif defined(__GNUC__) || defined(__INTEL_COMPILER)                           \
  || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590)                              \
  || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590)
    unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
#else
    unsigned char _[64];
#endif
} zmq_msg_t;

Which results in errors (LDC 1.41.0):

/opt/homebrew/include/zmq.h(228,50): Error: alignment value expected, not `sizeof`
    unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
                                                 ^
/opt/homebrew/include/zmq.h(228,57): Error: found `(` when expecting `)`
    unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
                                                        ^
/opt/homebrew/include/zmq.h(228,58): Error: found `void` when expecting `)`
    unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
                                                         ^
/opt/homebrew/include/zmq.h(228,63): Error: found `*` when expecting `)`
    unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));
                                                              ^
/opt/homebrew/include/zmq.h(228,64): Error: `;` or `,` expected
    unsigned char _[64] __attribute__ ((aligned (sizeof (void *))));

pinver avatar Nov 27 '25 18:11 pinver

@Emmankoko

thewilsonator avatar Nov 27 '25 23:11 thewilsonator

noted. let me quickly look through.

Emmankoko avatar Nov 28 '25 05:11 Emmankoko

run a lot of test here, this issue has been fixed in current. maybe version upgrade might do the magic @pinver @thewilsonator

Emmankoko avatar Nov 28 '25 11:11 Emmankoko