[4898] in Athena Bugs
vax 6.4r Hesiod library lint error
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Wed May 9 05:59:30 1990
Date: Wed, 9 May 90 05:58:54 -0400
From: "Jonathan I. Kamens" <jik@pit-manager.MIT.EDU>
To: marc@MIT.EDU
Cc: marc@MIT.EDU, epeisach@ATHENA.MIT.EDU, bugs@ATHENA.MIT.EDU
In-Reply-To: [4896]
From: marc@ATHENA.MIT.EDU
Reply-To: marc@MIT.EDU
Usmail: Marc Horowitz, 3 Ames Street, Cambridge, MA 02139
Phone: (617)225-6447
Date: Wed, 09 May 90 05:48:04 EDT
>> In our environment, malloc() returns a char *. The man page says
>> so. It is therefore correct to declare it as an extern function
>> returning a char *.
Not in any code I write. I'll cast, first. I usually cast, anyway,
for just this reason. You never can be sure.
And then lint will complain. If lint complains, you're wrong.
You are supposed to declare functions before using them. That's
what K&R says, and that's why the man pages for functions give you
their return types, so you can declare them. Using casting to
eliminate the necessary declarations is just sloppy programming.
If you're so worried about ANSI C, then put the declaration in an
#ifndef __STDC__ and put #include <stdlib.h> in the other have of the
#ifndef.
This discussion no longer belongs in bugs, I think. However, I
would strongly suggest that if you're writing code for Athena, you do
the declarations properly, because if we run lint over something
you've written in the source tree, and it complains, we're going to
put in the declaration, and we're going to flame at you (as the
developer) for not putting it in.
Incidentally, there are architectures which won't allow you to cast
an int to a pointer type. And then what will happen with your
casting?
jik