Re: [cc65] Re: possible error?

From: Spiro Trikaliotis <ml-cc651trikaliotis.net>
Date: 2009-07-28 21:08:46
Hello,

* On Tue, Jul 28, 2009 at 01:57:53PM +0200 Johan Kotlinski wrote:
> ...and this code produces an error with 2.12.9, but not 2.12.0:
> 
> void fn() {}
> typedef void (*FN)(void);
> const FN fns[] = { fn };

Does removing "const" fix it? Here, it does not.

What fixes the problem, however, is changing

 const FN fns[] = { fn };
to
 const FN fns[] = { &fn };



Just a personal note: I would prefer the style

 typedef void FN(void);
 const FN *fns[] = { fn };

But YMMV.


> > void fn() {}
> >
> > void main()
> > {
> >    unsigned char a;
> >    (a ? fn : fn)();
> > }
> >
> > ....I get this error with 2.12.0 and 2.12.9:
> >
> > test.c(6): Error: Incompatible types
> > cc65: Check failed: SPtr != 0, file `xsprintf.c', line 571

Changing 
    (a ? fn : fn)();
to
    (a ? &fn : &fn)();

fixes the problem.

Uz, it seems the automatic propagation to function pointers does not
work?

Regards,
Spiro.

-- 
Spiro R. Trikaliotis                              http://opencbm.sf.net/
http://www.trikaliotis.net/                     http://www.viceteam.org/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jul 28 21:09:04 2009

This archive was generated by hypermail 2.1.8 : 2009-07-28 21:09:07 CEST