comp.lang.ada
 help / color / mirror / Atom feed
From: Dave Thompson <david.thompson1@worldnet.att.net>
Subject: Re: C to JVM, time to revive JGNAT?
Date: Mon, 21 Aug 2006 06:04:51 GMT
Date: 2006-08-21T06:04:51+00:00	[thread overview]
Message-ID: <ll5ie2lcl5pkgn8aavm45fq46j780g20nt@4ax.com> (raw)
In-Reply-To: iXNCg.12548$E02.4627@newsb.telia.net

On Thu, 10 Aug 2006 21:55:26 GMT, Bj�rn Persson
<spam-away@nowhere.nil> wrote:

> As a quick example of a non-portable aspect of standard C, let's say I 
> need to represent natural numbers from 1 to 1000000. Which data type 
> should I use to ensure that the program will be portable to all 
> platforms that can handle these numbers? In C 99 there is *finally* a 

unsigned long. Guaranteed since C89 to be _at least_ 32 bits hence 0
to 4G-1. (It may be more.) As usual for C, doesn't check that your
values are in the given (or any other) subrange. The harder question
is for anything over unsigned 4G or signed 2G.

> set of portable integer types. Can I count on those being available in 
> all compilers?

[u]int_{least,fast}{8,16,32,64}_t must be present in any conforming
C99 implementation. Of which there are not many currently. Although
it's easy enough to patch any C89 implementation that has some 64-bit
(at least) integers, which most do, and your standard code works.

[u]int{8,16,32,64}_t must be present _if_ the implementation has (2sC)
integer types of the given exact sizes, as practically all machines do
nowadays. However, on an oddball machine with S&M or 18-bit word or
32-bit word and no halfword instructions, they can be left out. You
can portably _detect_ this by #ifdef INT64_MAX etc.

Other N's are up to the implementation, and probably quite rare.

- David.Thompson1 at worldnet.att.net



  parent reply	other threads:[~2006-08-21  6:04 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09  8:11 C to JVM, time to revive JGNAT? Dmitry A. Kazakov
2006-08-09  9:48 ` Jean-Pierre Rosen
2006-08-09 10:15 ` Georg Bauhaus
2006-08-09 10:59 ` Colin Paul Gloster
2006-08-09 16:01   ` Martin Krischik
2006-08-10  7:18     ` Maciej Sobczak
2006-08-10 10:08       ` Martin Krischik
2006-08-09 22:39   ` Björn Persson
2006-08-09 23:58     ` Georg Bauhaus
2006-08-10 22:31       ` Björn Persson
2006-08-11  9:51         ` Georg Bauhaus
2006-08-10  7:10     ` Maciej Sobczak
2006-08-10 19:38       ` Simon Wright
2006-08-10 21:55       ` Björn Persson
2006-08-11  7:54         ` Martin Krischik
2006-08-11  8:04         ` Maciej Sobczak
2006-08-11  9:00           ` Dmitry A. Kazakov
2006-08-14  7:09             ` Maciej Sobczak
2006-08-14  8:01               ` Dmitry A. Kazakov
2006-08-14  9:33                 ` Maciej Sobczak
2006-08-14 11:47                   ` Dmitry A. Kazakov
2006-08-21  6:04         ` Dave Thompson [this message]
2006-08-10  2:53   ` napi
2006-08-10 10:43     ` Colin Paul Gloster
2006-08-10 11:14       ` Martin Krischik
2006-08-21  6:04     ` Dave Thompson
2006-08-09 16:01 ` Martin Krischik
2006-08-09 18:13   ` Dmitry A. Kazakov
2006-08-10 10:11     ` Martin Krischik
2006-08-10 13:26       ` Dmitry A. Kazakov
2006-08-10 17:07         ` Martin Krischik
2006-08-10 19:18           ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox