Re: Re: [cc65] why this doesn't work?

From: Thomas Giesel <skoe1directbox.com>
Date: 2010-06-08 09:18:46
> Ah yes, that's got to be the most absurd thing about a language known 
> for its portability.  

This has been done to get the highest performance on each platform. Initially C was made to become a kind of portable assembler. So performance was at least as important as portability. Luckily they didn't to the same as in Pascal :)

It would be slow to implement an int in 32 bits on 6502. On the other hand it would be slow to implement a 16 bit int on many 32 bit RISC CPUs because they often have to erase or extend the higher bits manually. That's why it's very sane not to define a fixed width e.g. for int and unsigned int. Same with char: e.g. there are DSPs which can't address a single byte.

If you need signed/unsigned types with fixed width you may want to have a look into stdint.h. This is standardized by C99 and already contained in cc65. The types are called int16_t, uint8_t etc. 
(see also http://www.squarebox.co.uk/cgi-squarebox/manServer/usr/share/man/man0p/stdint.h.0p)

Regards,
Thomas


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jun 8 09:18:57 2010

This archive was generated by hypermail 2.1.8 : 2010-06-08 09:19:00 CEST