PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

PGI C Compiler: Support for packed structure?

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Raghu Reddy



Joined: 04 Sep 2012
Posts: 1

PostPosted: Thu Sep 20, 2012 10:50 am    Post subject: PGI C Compiler: Support for packed structure? Reply with quote

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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6218
Location: The Portland Group Inc.

PostPosted: Thu Sep 20, 2012 11:19 am    Post subject: Reply with quote

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

Code:

% 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
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group