vanam srihari kumar wrote:
Dear All
I am using gpc 2.1 version on sun solaris 2.8 .
I have problem with the accesing structures containing real variables.
I observed following things
- I checked size of structures containing real
varibles using sizeof function,I found out that memory allocated is always in multiples of 8,If I use -fpack-struct option it is allocating correctly but I am unable to access the address of my struct variable as it is packed?
GPC real is the same as C double, so on Sparc it takes 8 bytes and requires 8 byte alignment. So size beeing multiple of 8 is "correct" and anything else is "incorrect". If you really need different layout, you can force it, but you may run into troubles
Sparc is a strict alignment machine
- I am always getting 'signal SIGSEGV, Segmentation
fault' error while accessing real variables of my structures.I am suspecting some problem with memory allocation of structures containing real variables.One Interesting thing is, it is not happening with all structures containg real variables but only few.There is no problem with stack overflow.
Do you mean access from Pascal or access from C? If from C then note that Sparc is a strict alignment machine and will crash if you access misaligned data, so the problem may be due to packing (however, IIRC you would get BUS ERROR). If the problem is due to packing/alignment the simplest solution is to let GPC to properly align your data. If you need different alignment in records you must first copy record fields to aligned variables and access the copy.