i didn't received any response..........
and below is my original question,
i think maybe, #pragma pack(1) had been checked on Sparc stations but not
with x86's.
-haydee : )
---------------------- Forwarded by Haydee Y. Ching/ADTXP on 12/13/99 04:57
PM ---------------------------
From: Haydee Y. Ching on 12/11/99 03:49 AM
To: sun-managers@sunmanagers.ececs.uc.edu
cc:
Subject:
can someone check if this is a bug?
Running:
---------------------------------------------------------------------------
-----------------
#include<stdio.h>
# pragma pack(1)
typedef struct Zx{
char T1;
unsigned char T2;
long T3;
}ZZ;
int main(){
ZZ z;
printf("%p\n", &z.T1);
printf("%p\n", &z.T2);
printf("%p\n", &z.T3);
return 1;
}
---------------------------------------------------------------------------
-----------------
gave the following result:
---------------------------------------------------------------------------
-----------------
# uname -a
SunOS haydee 5.7 Generic_106542-04 i86pc i386 i86pc
# pwd
/opt/SUNWspro/SC3.0.1/bin
# ./CC /o1.cc
# ./a.out
804764c
804764d
8047650
#
---------------------------------------------------------------------------
-----------------
with sparc,
---------------------------------------------------------------------------
-----------------
which cc = /opt/SUNWspro/bin/cc
uname -a SunOS <machine name> 5.7 Generic sun4u sparc SUNW,Ultra-4
struc.c:
#include <stdio.h>
#pragma pack(1)
struct
{
unsigned char a;
unsigned char b;
long c;
} data;
main()
{
printf("&data.a = 0x%08lx\n",&data.a);
printf("&data.b = 0x%08lx\n",&data.b);
printf("&data.c = 0x%08lx\n",&data.c);
}
This displayed:
&data.a = 0x00020ba4
&data.b = 0x00020ba5
&data.c = 0x00020ba6
Removing the pragma gave:
&data.a = 0x00020ba4
&data.b = 0x00020ba5
&data.c = 0x00020ba8
-haydee : )
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:13:34 CDT