How to fix the mismatch struct size

test123 test123 at gmail.com
Mon May 16 05:57:33 UTC 2022


```c
typedef struct {
   const char *str;
   size_t      len : 30;
   bool        initial : 1;
   bool        final : 1;
} VTermStringFragment;

struct VTerm
{
   const VTermAllocatorFunctions *allocator;
   void *allocdata;

   int rows;
   int cols;

   struct {
     unsigned int utf8:1;
     unsigned int ctrl8bit:1;
   } mode;

   struct {
     enum VTermParserState {
       NORMAL,
       CSI_LEADER,
       CSI_ARGS,
       CSI_INTERMED,
       DCS_COMMAND,
       /* below here are the "string states" */
       OSC_COMMAND,
       OSC,
       DCS,
       APC,
       PM,
       SOS,
     } state;

     bool in_esc : 1;

     int intermedlen;
     char intermed[INTERMED_MAX];

     union {
       struct {
         int leaderlen;
         char leader[CSI_LEADER_MAX];

         int argi;
         long args[CSI_ARGS_MAX];
       } csi;
       struct {
         int command;
       } osc;
       struct {
         int commandlen;
         char command[CSI_LEADER_MAX];
       } dcs;
     } v;

     const VTermParserCallbacks *callbacks;
     void *cbdata;

     bool string_initial;
   } parser;

}
```

VTermStringFragment for mingw-x64 clang size is 24, for unix-64 
is 16.

VTerm for mingw-x64 clang size is 144, fox unix-64 is 208.

VTerm for mingw-x86 clang size is 128.

and offsetoff also diff from unix.


how to translate this into D struct ?


Is this problem cause by clang has wrong layout?







More information about the Digitalmars-d mailing list