Subject: Re: Problems with gdb under NetBSD 1.0
To: der Mouse <firstname.lastname@example.org>
From: Bakul Shah <email@example.com>
Date: 12/13/1994 11:33:22
> that everyone who wrote lseek(fd,(long)off,L_SET) was following your
Actually this started because
a) on some (all?) pre VAX systems int was 16 bit, and long int 32 bits.
b) K&R C did not have function prototypes, and,
c) for some weird reason people wanted to work on files > 32Kbytes :-)
This meant that if you wanted to pass an int where a long
argument was expected, you *had* to tell the compiler to
apply the (long) conversion. Thanks to prototypes now the
offset argument is silently coerced to off_t (if the
prototype is in the scope). As we all know, old habits die
hard and users have to be actively `educated' to make them
change their habits. Though this problem typically bites
porters of old software.
> Of course, that leaves the problem of what header file to include to
> get the prototypes, and _that_ changes much more than the actual type
> of the argument does.
This is a major problem. The usual way out is to create a
declaration of your own but then it conflicts with a
declaration of the same thing in a vendor provided include
file. I consider writing your own prototype to be
equivalent to casting the whole damn call! Alas, it is not
always possible to avoid it.
Someone ought write a book on porting software and how to
write portable software.