PGI C Compiler: Support for packed structure?

Does PGI C compiler support packed C structure?

Example (that GNU and Intel support):

struct ti_header {
inttype size,code,dh,typesize,count;
char data;
} attribute((packed));

If not, is there something equivalent?

Thanks,

–rr

Hi rr,

Yes, PGI supports the packed attribute. This particular struct doesn’t need to be packed but if data was a single char, then you can see it when printing out the size of the struct.

Hope this helps,
Mat

% cat test1.c 
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
typedef long inttype;

struct ti_header {
inttype size,code,dh,typesize,count;
char data;
#ifdef USE_PACKED
} __attribute__((packed));
#else
};
#endif

void main () {
  
   struct ti_header ti;
   printf("%d\n", sizeof(ti));
   exit(0);
}

% gcc test1.c ; a.out
48
% gcc test1.c -DUSE_PACKED ; a.out
41
% pgcc test1.c ; a.out
48
% pgcc test1.c -DUSE_PACKED ; a.out
41