Re: data types




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.

.



Relevant Pages

  • Re: switching context on MSP430
    ... registers R15,R14,R13 and R12on stack. ... are you aware that not every c compiler for the MSP430 ... Preemption vs Cooperation ... Another important decision to make is whether or not a real-time clock ...
    (comp.arch.embedded)
  • Re: Ive seen the future...and it works! (was: my view on this assembler is blah)
    ... The compiler has the advantage, granted, that it can "remember" what all ... the registers are...but "remembering" isn't the challenge here, ... registers with the CPU... ... The HLLs, though - shackled by a whole bunch of factors that they have to ...
    (alt.lang.asm)
  • Ive seen the future...and it works! (was: my view on this assembler is blah)
    ... > though the registers are few. ... And the 64 bit CPU designers ... what my Borland _C++ compiler_ does when you ask for assembly output...it ... out programming with something like BASIC or Pascal, ...
    (alt.lang.asm)
  • Re: Dell wakes up
    ... But what about the Intel Coreseries? ... The registers are still 32bit. ... architecture will use the whole 64 bit regsiter? ... The software needs to be compiled by a compiler aware of the ...
    (rec.sport.football.college)
  • Re: 32-bit vs. 64-bit x86 Speed
    ... You compiler people probably have intimate knowledge of the ISA ... What is the underlying chip architecture and memory subsystem? ... Do you use the x87 floating point stack or xmm registers? ... Do you use of tuned math and string libraries? ...
    (comp.compilers)