From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bcdd81f11a99e024 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail From: Dave Thompson Newsgroups: comp.lang.ada Subject: Re: C to JVM, time to revive JGNAT? Message-ID: References: <20060809124902.O84175@docenti.ing.unipi.it> <8utCg.12454$E02.4571@newsb.telia.net> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Mon, 21 Aug 2006 06:04:51 GMT NNTP-Posting-Host: 12.76.14.81 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1156140291 12.76.14.81 (Mon, 21 Aug 2006 06:04:51 GMT) NNTP-Posting-Date: Mon, 21 Aug 2006 06:04:51 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:6285 Date: 2006-08-21T06:04:51+00:00 List-Id: On Thu, 10 Aug 2006 21:55:26 GMT, Bj�rn Persson 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