*Michel --*

Your program is legal C syntax, really!
A way to visualize this is to replace myFunc) { .. } with some kind of
array, "char  bites[5];" in your code below.  Sometime you access "bites[2]"
and sometimes you just use the name "bites" e.g. on a memset() call, to get
a pointer to the memory.

If you want a function *pointer*, use only "myFunc" without the parens.
 That way you do not de-reference the symbol.

    memset( bites, 0, 5 );    // here "bites" is a pointer to some memory.
    void (*pfv)() = myFunc;    // here "myFunc" is a pointer to a function.
                                        // "pfv" == pointer to a function
returning 'void'


In this case, SDCC could issue a warning such as "statement has no
side-affect".  Use a different compiler and crank up the warnings to see
what you get.


HTH,
*the other brian


On Fri, Oct 16, 2009 at 4:14 PM, Michel Bouissou
<[email protected]>wrote:

> Hi folks,
>
> I've spent hours trying to debug this problem and I wonder if it's normal
> or a
> sdcc compiler shortcoming :
>
> I have a function defined as
>
> void myFunc() {
>        blah;
>        blah;
> }
>
> In my program I had a :
>
> if (complex && conditions) {
>        blah;
>        blah;
>        blah;
> } else myFunc;
>
> I noticed that the positive branch of the "if" was properly executed when
> it
> had to, but for some reasons the contents of "myFunc" semt to never be
> executed.
>
> I first spent a lot of time checking and debugging the contents of "myFunc"
> and
> found nothing. Then I spent hours debugging the conditions and the "if"
> structure and still found nothing.
>
> I finally found out that I was calling "myFunc" instead of "myFunc()" and
> the
> compiler then simply ignored the function call and never performed it,
> without
> a single warning or error message during compilation.
>
> I don't know if it's "normal C behaviour" as I'm not very experienced with
> C
> or if it's a compiler issue, I only know how frustrated I got discovering
> that
> I had lost that much time because of a missing ()...
>
> I would have expected a compiler message about the missing parentheses in
> the
> function call...
>
> So I report it here anyway, just in case... :-\
>
> --
> Michel Bouissou (OpenPGP ID 0xEB04D09C)
>
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to