Re: data types
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 3 Mar 2007 00:22:55 -0800
Rahul wrote:
Please don't top-post.
[fixed]
koolj96825@xxxxxxxxx wrote:
Hi,
I've been working on this project for the past few months in my spare
time, and now I started working on the windows interface and going
over my petzold book, I've come to the realization that an int could
be 32-bit for PCs. Oh, I could kick myself for not checking good in
the beginning, but the manual for the compiler I am using says int is
16-bit. It may be out of date.
Anyway, now that I need to go back over and look closely at my code,
my question is: is there a way to declare a variable say a 16 bit
unsigned integer in C? Or is declaring it "short" the only specifier
that may work?
Thanks in advance
Hi Guys,
i just want to extend the topic a little further.....
what governs the size of a data type? is it the computer architecture
or the compiler which is generating the executable code for a
particular architecture?
Usually a system's compiler makes choices based on the underlying
architecture of the system. Most systems have a natural word size,
(which is usually the width of the processor's general purpose
registers), they also have a byte as the smallest independently
addressed data unit. They may also provide special data objects, (like
floating point and SIMD registers), larger than the general purpose
registers etc.
The compiler makes it's choices based on the target system. Usually
the int type corresponds to the machine's word, char is implemented on
a byte and others like float and long long may be implemented with the
system's floating point unit and other special registers.
Also, does the compiler take care of the endianness of the machine?
Endianess isn't much of an issue since the compiled machine code is
specific only to that machine type. It does become an issue when data
is exchanged between systems, but that's not within the purview of the
compiler. Usually system routines take care of the translation.
What is the case with a cross compiler in such situations?
The cross compiler emits object code for it's target, with it's
endianess accounted for. The host system doesn't matter, other than
hosting the compiler itself.
.
- References:
- data types
- From: koolj96825
- Re: data types
- From: Rahul
- data types
- Prev by Date: Re: How To Implement Timer in C
- Next by Date: Re: data types
- Previous by thread: Re: data types
- Next by thread: Re: data types
- Index(es):
Relevant Pages
|