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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,4873305131bf4d94 X-Google-Attributes: gid109fba,public From: "Shmuel (Seymour J.) Metz" Subject: Re: Porting Experiences (was Ada and Pascal etc ) Date: 1997/11/04 Message-ID: <345F95D0.3984@gsg.eds.com>#1/1 X-Deja-AN: 287086977 References: <34557f2b.1934172@news.mindspring.com> <345BB35E.4488@dynamite.com.au> <63ftj9$r9g@bgtnsc02.worldnet.att.net> <345E3ACD.A15@gsg.eds.com> <63mcmm$r3s$1@helios.crest.nt.com> Organization: EDS MS Reply-To: nospam@gsg.eds.com Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Date: 1997-11-04T00:00:00+00:00 List-Id: Kaz Kylheku wrote: > > That depends on how you look at it. I'd say that it requires a little > more thought and skill to write portably with types that have sizes > that are not fully specified, but it's not impossible. > > C gives you a header, , which gives you the constants LONG_MIN > and LONG_MAX. These tell you what the implementation's least and > greatest values of type long are. These values are guaranteed to be > at least -2^31+1 and 2^31-1 respectively. > > If you assume that the long type has a range that is no larger than this, > you are OK. If you write your code under the assumption that the > range is LONG_MIN to LONG_MAX, you are also OK. > > Sure, you might not be able to declare subtypes with more restricted ranges > like in Ada, but that doesn't mean that portability has gone out the window! So the portable way to declare 33-bit integers is to declare them as long and let them be 128 bits on some machines? I don't consider that a viable option. To restate, there is no portable way to cause the compiler to chose a size that is the best compromise between the problem requirements and the natural byte sizes of the machine. In Ada I give a range of values and the compiler figures out whether to use, e.g., words, half words or double words. In PL/I I give a number of bits (for binary) or a number of digits (for decimal) and the compiler figures it out. In C I have to play games with, e.g., multiple versions of my headers. Unless and until the new standard passes, this aspect of C will remain a serious blot on the claims of portability. -- Shmuel (Seymour J.) Metz Senior Software SE The values in from and reply-to are for the benefit of spammers: reply to domain eds.com, user msustys1.smetz or to domain gsg.eds.com, user smetz. Do not reply to spamtrap@library.lspace.org