[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] MiNTLib 0.51



Hi!

On Wed, May 12, 1999 at 10:43:55PM +0300, t150315@students.cc.tut.fi wrote:
> > > Can't you instruct gcc to issue a warning when calling a function without
> > > prototype?
> >
> > Option -Wall
> 
> IMHO -Wmissing-prototypes is also needed.  That way you get warning
> also if the function is defined without a prototype (ie function
> source doesn't include it's prototype header).  I've catched a few
> additional bugs that way.

Julian, you mentioned that PureC needs prototypes to produce the correct
code.  Could you clarify this?  MiNTLib 0.51.1 (the next version) contains
a couple of functions which differ from the actual prototypes, e. g.:

int gettimeofday (long tv, long tz)
{
  ...
}

The prototype from <sys/time.h> looks like:

  extern int gettimeofday (struct timeval* __tv, struct timezone* __tzp);

and that's why <sys/time.h> doesn't get included.

Will this cause problems with PureC?  There are quite a few files like
that and the function headers are wrong because these files are generated
and I only cared about the size of the data types, not the exact
definition.

Another possible problem with that:  Will PureC mask out the upper 16 bits
of the return value if a function returns a short int?  Example:

foobar.c:
long foobar ()
{
  return 666666; /* More than SHORT_MAX!  */
}

main.c:
extern short int foobar();  /* Wrong prototype!  */

int main ()
{
  printf ("result: %d\n", foobar ());
}

Will that produce "666666" or "666666 & 0xffff"?

Sure, this is somewhat a hack but as I said before, these files are
generated and I want to reduce the work with that.

Ciao

Guido
-- 
http://stud.uni-sb.de/~gufl0000
mailto:gufl0000@stud.uni-sb.de