delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/22/18:11:33

Xref: news-dnh.mv.net comp.os.msdos.djgpp:4609
From: engstad AT funcom DOT com (Paal-Kristian Engstad)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: aligment / based pointers
Date: 21 Jan 1996 01:30:44 GMT
Organization: Funcom Productions.
Lines: 60
Message-ID: <4ds504$j63@odin.funcom.no>
References: <960118222321_100662 DOT 3563_EHV63-1 AT CompuServe DOT COM>
NNTP-Posting-Host: odin.funcom.no
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Fulco Bohle (100662 DOT 3563 AT compuserve DOT com) wrote:
: #pragma pack(4)		/* initiates 4-bytes alignment */
: 
: typedef struct
: 	{
: 	char	aap;		/* dutch for monkey */
: 	int	noot;		/* dutch for nut */
: 	} s_leesplankje;		/* this is how I learned to read */
: 
: sizeof (s_leesplankje) = max( sizeof( char), 4) + sizeof( int)
: 
: #pragma pack(2)		/* initiates 2-bytes alignment */
: 
: typedef struct
: 	{
: 	char	aap;
: 	int	noot;
: 	} s_leesplankje;
: 
: sizeof (s_leesplankje) = max( sizeof( char), 2) + sizeof( int)	
: 
: How do I obtain the same results in DGGPP-C

The gcc compiler does not like #pragma's, because it is difficult, if not 
impossible to make the code portable. This is the solutions:

/* #pragma pack(4) */

typedef struct {
	char monkey; /* Takes full 4 bytes. */
	int  nut;
} mystruct1;

/* #pragma pack(2) */

#define PACKED __attribute__ ((packed))

typedef struct {
	char monkey   PACKED;
	char pad1     PACKED;
	int  nut      PACKED;
} mystruct2;

: 2. Does DJGPP-C understand based pointers ?

What is a based pointer?

: 3. What is the main difference between djgpp verion 1.12 and 2.0 ?

Main differences are the evolution from 'go32' to use external DPMI 
extenders. (Along with a couple of fixups and general improvements, of 
course.)

: Fulco Bohle
: 

----------------------------------------------------------------------
| P†l-Kristian Engstad | engstad AT funcom DOT com  | Games programmer, PSX |
| Funcom Productions   | Ph +47 22 42 01 02  | developer & Linux Fan |
----------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019