Skip to main content
Visitor II
July 26, 2007
Question

Bug with array of pointers to functions in Cosmic V4.5.5?

  • July 26, 2007
  • 3 replies
  • 962 views
Posted on July 26, 2007 at 04:24

Bug with array of pointers to functions in Cosmic V4.5.5?

    This topic has been closed for replies.

    3 replies

    davidsAuthor
    Visitor II
    July 23, 2007
    Posted on July 23, 2007 at 02:27

    I think I may have found a bug in the Cosmic compiler V4.5.5. This indirect call with one parameter compiles perfectly:

    *******************************

    int FunctionOne(unsigned int x)

    {

    }

    void main(void)

    {

    int FunctionOne(unsigned int);

    const int (*jumpTable[])(unsigned int) =

    {

    &FunctionOne

    };

    jumpTable[0](1);

    }

    *******************************

    But, when you add another parameter, the compiler says ''invalid indirect call'':

    *******************************

    int FunctionTwo(unsigned int x, unsigned int y)

    {

    }

    void main(void)

    {

    int FunctionTwo(unsigned int, unsigned int);

    const int (*jumpTable[])(unsigned int, unsigned int) =

    {

    &FunctionTwo

    };

    jumpTable[0](1, 2);

    }

    *******************************

    Am I doing something wrong?

    -David

    Visitor II
    July 24, 2007
    Posted on July 24, 2007 at 06:33

    Hello,

    static memory models and functions called by pointer do not work well together: if you limit the arguments at 2 bytes it will still do because the arguments are passed in registers, but if you need more you must declare the called function @stack (or use a non static memory model).

    Regards,

    Luca (Cosmic)

    davidsAuthor
    Visitor II
    July 26, 2007
    Posted on July 26, 2007 at 04:24

    Thank you!