delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/20/13:34:23

Message-ID: <32E4505B.7ED0@post.comstar.ru>
Date: Mon, 20 Jan 1997 21:12:59 -0800
From: Dim Zegebart <zager AT post DOT comstar DOT ru>
Reply-To: zager AT post DOT comstar DOT ru
Organization: zager AT post DOT comstar DOT ru
MIME-Version: 1.0
To: DJGPP Mail List <djgpp AT delorie DOT com>
Subject: Bug in DJGPP or some my Error?

Hi,

Try this code. 
Here i declare some struct with
members of unsigned char and unsigned int.
I think what sizeof(unsigned int)+sizeof(unsigned char)=5,
but I'm wrong! :-(
DGJPP think another way:

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

#define BFLAG unsigned char //I think sizeof(BFLAG) - 1 byte
#define HND   unsigned int  //I think sizeof(HND) - 4 byte

typedef struct
{
  BFLAG nCode;
  HND   hItem;
} TItem;

void main (void);

void main(void)
{
  TItem pItem;

  clrscr();

  printf ("Size of BFLAG : %d\n",sizeof(BFLAG)); // 1
  printf ("Size of HND   : %d\n",sizeof(HND));   // 4 
  printf ("Size of TItem : %d\n",sizeof(TItem)); // 8
}

What i missing ?
Is it another trick of memory alligment ?

-- 
Regards,
Dim Zegebart,
Moscow Russia.

- Raw text -


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