Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Application Exercises
Date: Wed, 10 Apr 2019 08:15:12 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <86d0ltki2n.fsf@mailhub.linuxsc.com>
References: <86pnpvjtr7.fsf@mailhub.linuxsc.com> <86h8b6jyys.fsf@mailhub.linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="ce4bd472135452134bd6131c492cf926"; logging-data="11040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18C6unpwc9LIkOaMNU7aUSEIFbFJmybm78="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:qgATo74iWhp50wpx7vdj/jE8ayU= sha1:6LgmtWI6otYmN7A8CqCogFIb5sY=
Xref: csiph.com comp.lang.c:142964
Richard Damon writes:
> On 4/9/19 11:55 PM, Tim Rentsch wrote:
>
>> The code I wrote has one pre-processor comparison, to allow the
>> code to work in different versions of C. The test is this:
>>
>> #if __STDC_VERSION__ > 199900
>>
>
> I guess that you need the __STDC_VERSION__ test to know a name for
> the largest signed type and not assuming you are dealing with an
> int, but some arbitrary integer type.
Yes. I wanted one routine for all signed types. The natural
type for that is intmax_t, but that isn't available in pre-C99
environments, hence the pre-processor test.
> Thinking about it a bit more, I think I can figure out how to
> do this differently without needing the size of an int.
Great! Reading your comments also has given me an idea for
an improvement to my previous solution.