home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!uwm.edu!bionet!turbo.bio.net!will
- From: will@turbo.bio.net (Will Nelson)
- Newsgroups: comp.lang.c
- Subject: sizeof()
- Message-ID: <Sep.9.14.38.29.1992.10548@turbo.bio.net>
- Date: 9 Sep 92 21:38:29 GMT
- Organization: GenBank Computing Resource for Mol. Biology
- Lines: 49
-
- I've run into an incompatibility between Microsoft C 7.0
- and the unbundled ANSI C compiler (1.1) of SUN Microsystems.
-
- The deal is that the input file is a series of structs
- that were written with fwrite on the DOS system. When I
- fread the structs on the program compiled with Microsoft C
- 7.0 on DOS, they get read correctly. When I fread the structs
- using the program compiled with SUN's acc on UNIX, the fread's
- do not fill the buffer correctly. I have tracked it down
- to a difference in what the sizeof() operator returns.
-
- Here is the struct:
-
- extern struct Feature_Form Feature_Form_Buffer;
-
- struct Location {
- char base_position[7];
- int operator_token;
- };
-
- struct Feature_Form {
- char ain_label[3]; /* 1 or 2 letter unique identifier for feature */
- char feature_key[16];
- char user_defined_feature_label[16];
- char complement; /* flag set if complement chosen from format */
- struct Location Start_Location;
- struct Location End_Location;
- };
-
-
- The fread's are done like this:
-
- while (fread(&Feature_Form_Buffer, sizeof(Feature_Form_Buffer), 1, mainfptr) =
- = 1) {
-
-
- If I look at what sizeof(Feature_Form_Buffer) produces, it comes out
- as 56 on the DOS side and 60 on the UNIX side.
-
- Needless to say, this looks like a show-stopper.
- I've given up on trying to determine which is the "Correct" behavior,
- mainly because I don't have the ANSI C standards document.
- What I want to know is, is there any way to get the UNIX acc compiler
- to give the same result as the DOS compiler? I would like to use
- the same code in both environments if at all possible.
- --
- Will Nelson
- Systems Programmer, IntelliGenetics, Inc.
- will@presto.ig.com
-