Re: [cc65] stack corruption

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2004-07-21 17:50:24
On Wed, Jul 21, 2004 at 03:28:30PM +0200, MagerValp wrote:
> >>>>> "UvB" == Ullrich von Bassewitz <uz@musoftware.de> writes:
>
> UvB> This is what I get:
>
> UvB> test.c(5): Error: Conflicting types for `DrawEntryDiskID'
>
> UvB> Are you sure, both declarations were visible to the compiler?
>
> drawentry.c does not include drawentry.h itself, so when the function
> is compiled it's not visible.

It's a golden rule that each C module should include it's corresponding header
file to catch errors like this.

The reason why the code works with gcc and not with cc65 is that gcc passes
characters as ints. This keeps the stack aligned, gives faster code, and works
even in the absence if a prototype. For cc65, passing all characters as ints
would be a big performance penalty, so if a prototype is in sight, char
parameters are actually pushed as characters. If you have different prototypes
(or no prototype at all), it will give slightly unexpected results:-)

> Implicit ints wouldn't (well, shouldn't) break any of my code at
> least, but maybe a --implicit-ints could be added.

--standard c89 will enable implicit ints.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jul 21 17:50:28 2004

This archive was generated by hypermail 2.1.8 : 2004-07-21 17:50:38 CEST