[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [MiNT] MiNTLib 0.51
> From: owner-mint@fishpool.com [mailto:owner-mint@fishpool.com]On Behalf
> Of Guido Flohr
> Sent: Thursday, May 13, 1999 4:01 AM
> To: MiNT mailing list
> Subject: 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.
This will certainly cause a problem because PureC passes long in data
registers and pointers in address register. So this might be fixed by using
"void *" instead of "long".
> 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.
This should work because according to the prototype in main.c, the type of
foobar() is int.
Who the hell is generating code like this? This would also fail on machines
where a similar parameter passing scheme is used, or where sizeof (long) !=
sizeof (void *).
Regards, jre