Subject: Re: gcc-ansi -pedantic and long long on NetBSD
To: Chris G. Demetriou <email@example.com>
From: Alan Barrett <firstname.lastname@example.org>
Date: 10/30/1994 22:56:13
On Sun, 30 Oct 1994, Chris G. Demetriou wrote:
> i'm aware of all of these things.
I would have been surprised if you were not; I just wanted to give some
background for this:
> > Apart from a possible desire to support broken code that assumes ints and
> > longs are each 32 bits, I see no reason why a C implementation that
> > desires to support 64-bit integers should not use 64-bit longs and 32-bit
> > ints.
> HOWEVER, the problem is that ANSI C give you no way of specifying
> explicit-length data types.
> file offsets are 64 bits. how do you specify that (using an integral
> type) in ANSI C, without forcing 'long' to be 64 bits on 32-bit
Let me do some thinking aloud. You probably know all this too, but
I do make an interesting suggestion near the end...
I believe that off_t is required to be an integral type, so you can't
play games with structures. If you want off_t to be 64 bits, then you
need a 64-bit integral type. If you want to be strictly compatible
with the ANSI C standard, the only integral types available are (signed
or unsigned) char, short, int and long. You probably want ints to be
narrower than 64 bits, so you are pretty much forced into making long a
64-bit type. I think that that would be OK.
If you don't care that much about strict ANSI C compatibility, then you
can make longs narrower than 64 bits, and invent a new, non-standard,
integral type of exactly 64 bits. I think that that is OK too, and that's
what has been done with "long long". However, we now get complaints from
the compiler in -ansi -pedantic mode about the use of the non-standard
"long long" type.
If you dont like the compiler complaints, there are a few obvious
solutions: Use 64-bit longs instead of inventing a non-standard 64-bit
type; or make the compiler believe that "long long" is a standard type;
or learn to live with the complaints although you don't like them; or
add a new compiler option to stop all complaints about "long long".
There is also a less obvious solution: Add a compiler option to stop
complaining about the use of "long long" in system include files, or
where it results from the use of a typedef that was defined in a system
include file (but to continue to complain about use of "long long"
elsewhere). Perhaps even make such suppression of warnings the default,
with an option to turn the warnings on.
--apb (Alan Barrett)