From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem using a struct Date: 8 Jan 2003 19:30:18 GMT Organization: Cornell University Lines: 29 Sender: asu1 AT cornell DOT invalid (on pool-141-149-206-240.syr.east.verizon.net) Message-ID: References: NNTP-Posting-Host: pool-141-149-206-240.syr.east.verizon.net X-Trace: news01.cit.cornell.edu 1042054218 20479 141.149.206.240 (8 Jan 2003 19:30:18 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 8 Jan 2003 19:30:18 GMT User-Agent: Xnews/5.04.25 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Joel Saunders" wrote in news:bcd4cba120fadbd18cb606881c88ae87 DOT 62691 AT mygate DOT mailgate DOT org: > I made a post about this yesterday, but it never showed up, so I'll > try again, and hope it posts this time. > For a basic bmp loader I made, the struct to hold the bmp header > doesn't work. I used __attribute__((__packed__)) after each item, but > it's no good. I gave the file for the program, a C extention, instead > of a cpp extention, so I know that probably makes some difference. > Here's the header... > struct BMP_Header { > unsigned int BM __attribute__((__packed__)); > unsigned long File_Size __attribute__((__packed__)); > Here's what I had to use instead of the header: > unsigned char image[54]; > #define image_BM ((int *)&image[0])[0] > #define image_File_Size ((long *)&image[2])[0] sizeof int on djgpp is 4, not 2. -- A. Sinan Unur asu1 AT c-o-r-n-e-l-l DOT edu Remove dashes for address Spam bait: mailto:uce AT ftc DOT gov