structure alignment on Suns...
Peter Morreale
morreale at bierstadt.scd.ucar.edu
Tue May 14 11:07:54 AEST 1991
I have an application in which I write/read structures to files.
In an earlier version, I was able to have both the Sun3 and Sun4
versions read/write the same files. I realize that I got lucky, since
the member alignment is different on the two machines.
Now however, I increased both the sizes and number of members
and things don't work between the two machines. I'd like to get that
functionality back if I can by playing games with member alignment if I
can.
Portability is *not* an issue here. This is a local app.
likewise, it will be a long time before we move off of the Suns.
Can someone familiar with this show me what needs to go where?
(and/or tell me if this is possible anymore?)
How does Sun align struct members? Word boundries? Of what size?
(as you will see most of the members are char arrays...)
As this may not be of general interest, email is fine......
Here is the current definition of the structure:
------------------start of indxstruct.h----------------------
/*
* Define the maximum number of chars for use in the structure.
* (includes the null byte)
*/
#define LISTCHARS 23
#define LOGCHARS 9
#define NMECHARS 32
#define PHNCHARS 20
#define EMLCHARS 39
#define DTECHARS 9
#define TMECHARS 5
#define LCTCHARS 27
#define RFRCHARS 11
#define DIVCHARS 6
#define AREACHARS 21
#define SEQCHARS 7
#define SCICHARS 5
#define USRCHARS 9
#define BUFCHARS 12
/* The index structure. This contains all the fields of a contact. */
typedef struct index {
long offset; /* offset in text file */
short len; /* len of note string */
char area[AREACHARS]; /* subject area */
char user[USRCHARS]; /* xconslog user's name */
char seq[SEQCHARS]; /* contact sequence. # */
char tmstmp[BUFCHARS]; /* Enter timestamp */
char scinum[SCICHARS]; /* Scientist number */
char list_str[LISTCHARS]; /* List string */
char log[LOGCHARS]; /* Contact logon name */
char nme[NMECHARS]; /* Contact name */
char tme[TMECHARS]; /* Time spent on contact*/
char phn[PHNCHARS]; /* Contact phone number */
char eml[EMLCHARS]; /* Email address */
char lct[LCTCHARS]; /* location of contact */
char div[DIVCHARS]; /* Contact division */
char dte[DTECHARS]; /* Contact enter date */
char d_dte[DTECHARS]; /* done date */
char del_con; /* delete flag */
char contact; /* type of contact */
char done; /* done flag */
char rpt; /* report flag */
char site; /* site flag */
char refer; /* referral flag */
char buffer2[BUFCHARS]; /* unused */
char flag2; /* unused */
} Construct;
extern Construct indx;
----------------end of indxstruct.h---------------------------
This certainly isn't critical as I can constrain the users to the
Sun4 machine, but if I can, I'd like this new version to match the old.
Thanks,
-PWM
------------------------------------------------------------------
Peter W. Morreale email: morreale at ncar.ucar.edu
Nat'l Center for Atmos Research voice: (303) 497-1293
Scientific Computing Division
Consulting Office
------------------------------------------------------------------
More information about the Comp.lang.c
mailing list