Help!

Size 8 bit, 16 bit, 32 bit and 64 bit systems.

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> System Development RSS
Next:  Size 8 bit, 16 bit, 32 bit and 64 bit systems.  
Author Message
adar
External


Since: Aug 01, 2007
Posts: 2



PostPosted: Wed Aug 01, 2007 3:34 pm    Post subject: Size 8 bit, 16 bit, 32 bit and 64 bit systems.
Archived from groups: comp>os>linux>development>system (more info?)

I need to find out what is the size of following data structures in 8
bit, 16 bit, 32 bit, and 64 bit systems.

struct findsize{

unsigned char chA;
unsigned long lg;
unsigned short sh;
unsigned char chB;
};


sizeof() runs at compile time, that means one can know in advance what
size of these. I don't have 8 bit or 16 bit systems. I do have 32 bit
and 64 bit system.

I believe, in 32 bit system, this would be 1+4+2+1 = 8 bytes.

Can anyone throw some light here on how to find size?
Back to top
phil-news-nospam
External


Since: Nov 16, 2006
Posts: 329



PostPosted: Thu Aug 02, 2007 1:18 am    Post subject: Re: Size 8 bit, 16 bit, 32 bit and 64 bit systems. [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 01 Aug 2007 15:34:56 -0700 adar <adar_ji DeleteThis @yahoo.com> wrote:

| I need to find out what is the size of following data structures in 8
| bit, 16 bit, 32 bit, and 64 bit systems.
|
| struct findsize{
|
| unsigned char chA;
| unsigned long lg;
| unsigned short sh;
| unsigned char chB;
| };
|
|
| sizeof() runs at compile time, that means one can know in advance what
| size of these. I don't have 8 bit or 16 bit systems. I do have 32 bit
| and 64 bit system.
|
| I believe, in 32 bit system, this would be 1+4+2+1 = 8 bytes.
|
| Can anyone throw some light here on how to find size?

The size can vary even between different systems of the same bit size.
If you need to know the size before compile, maybe you are also needing
to know the offset layout. Neither of these is a known until compile.

If you are trying to design a common way to communicate between programs
in different machine architectures, you should design structures in your
protocol independent of any machine. For example define fields as a
series of bytes in some order (big endian is the basic order for the
internet). Then code serializers and deserializers as functions to do
the grunt work.

--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2007-08-01-2015 DeleteThis @ipal.net |
|------------------------------------/-------------------------------------|
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> System Development All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum