M
Michael Hull
Hi Everyone,
I have a question, and I hope its not obvious!
As I understand it, C++does not define the number of bits in a byte,
this is architecture independant. The thing we always know are that
sizeof(char) == 1. The sizees of int, long, etc will be architecture
dependant, ie the number of bits in an int on a 32bit machine may be
different to that on a 64bit machine.
I am writing a program which writes information across a network, to
both 32 or 64 bit architectures. I am writing in Linux (sorry I don't
want to get os specific), what I do not understand is how I should
define my types. Basically, if I am writing out from a 32bit machine,
and readling from both 32 and 64 bit machines, how should I define my
datatypes. I hope this is not OT - I am using linux sockets, but I
guess the question applies for all os's/libraries.
I would have expected that some header file would define int8, int16,
int32, int64 for these kind of scenarios, and I'm sure that I have
seen these kind of definitions, but can seem to find them on my local
system, nor google.
Any advice would be gratefully appreciated,
Thanks
Mike
I have a question, and I hope its not obvious!
As I understand it, C++does not define the number of bits in a byte,
this is architecture independant. The thing we always know are that
sizeof(char) == 1. The sizees of int, long, etc will be architecture
dependant, ie the number of bits in an int on a 32bit machine may be
different to that on a 64bit machine.
I am writing a program which writes information across a network, to
both 32 or 64 bit architectures. I am writing in Linux (sorry I don't
want to get os specific), what I do not understand is how I should
define my types. Basically, if I am writing out from a 32bit machine,
and readling from both 32 and 64 bit machines, how should I define my
datatypes. I hope this is not OT - I am using linux sockets, but I
guess the question applies for all os's/libraries.
I would have expected that some header file would define int8, int16,
int32, int64 for these kind of scenarios, and I'm sure that I have
seen these kind of definitions, but can seem to find them on my local
system, nor google.
Any advice would be gratefully appreciated,
Thanks
Mike