delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/13/22:16:16

From: johan AT technologist DOT com (Johan Levin)
Newsgroups: comp.os.msdos.djgpp
Subject: Struct field aligning
Date: 13 Nov 1997 18:40:36 GMT
Organization: -
Lines: 29
Message-ID: <64fhj4$iev@mn5.swip.net>
NNTP-Posting-Host: dialup174-2-24.swipnet.se
Mime-Version: 1.0
NNTP-Posting-User: s-49839
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Look at this code:

#include <stdio.h>
#include <conio.h>

struct test_struct {
	int p1;
	char ch;
	int p2;
};

void main(void)
{
	struct test_struct test;
	printf("%p\n",&test.p1);
	printf("%p\n",&test.ch);
	printf("%p\n",&test.p2);
}

In this case all elements of the structure becomes
dword-aligned. That might be good for speed, but
I'm trying to read the header of a file that doesn't
align it's fields like this. Is it possible to disable
this aligning for a structure?

TIA

/Johan Levin

- Raw text -


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