TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Content-Transfer-Encoding: 7bit
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
From: Geoff Bull <[log in to unmask]>
Date: Wed, 11 Nov 1998 21:17:08 +1100
Content-Type: text/plain; charset=us-ascii
MIME-Version: 1.0
Reply-To: Geoff Bull <[log in to unmask]>
Parts/Attachments: text/plain (25 lines)
"W. Wesley Groleau x4923" wrote:

> My C books emphasize the fact that the size and range of anything other
> than "char" is not portable.

Even char is not portable!
It is signed on some platforms (range -128 .. 127)
and unsigned on others (range 0 .. 255).
This has caused me huge headaches porting code taht
had been written with no respect for this fact.
Actually the ranges above are not guaranteed, only typical.
By definition sizeof(char)==1 but a char is not necessarily 8 bits.

As Stroustrup wrote in 'The  C++ Programming Language':
"Writing truly portable low-level code is harder ... it is usually safe
to assume that a char can hold integers in the range 0 .. 127"

Of course, with Ada, we don't have to "assume" anything,
and we don't have to write programs that "usually" work.
And writing truly portable code is generally not that hard.