|
|
View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Function pointer comparison. Bug in v4.071? |
Posted: Fri Jun 27, 2008 12:01 am |
|
|
Colleagues,
It’s great that v4 supports function pointers. However, it doesn’t seem to support the function pointer comparison at the moment.
Code: |
typedef int8 (*fp)(int8, int8); // typedef for our function pointer
int8 do_it(int8 ix, int8 iy)
{
return (ix + iy);
}
// more functions that fit the fp typedef
void main()
{
// . . .
fpFoo = &do_it; // initialize the function pointer.
// . . .
if (fpFoo == &do_it) // during compilation, this line generates ERROR 48: Expecting a (
{
// . . .
}
// . . .
}
|
- Nick _________________ Read the label, before opening a can of worms.
Last edited by kender on Fri Jun 27, 2008 12:06 pm; edited 1 time in total |
|
|
Ttelmah Guest
|
|
Posted: Fri Jun 27, 2008 2:05 am |
|
|
The function name itself, _is_ the function's address. You don't need the '&' when referring to it.
Use a cast for comparisons. Given that fpFoo, is the address of a function, it expects to receive two variables. So:
Code: |
typedef int8 (*fp)(int8, int8); // typedef for our function pointer
int8 do_it(int8 ix, int8 iy)
{
return (ix + iy);
}
// more functions that fit the fp typedef
void main()
{
// . . .
fp fpFoo;
fpFoo = do_it; // initialize the function pointer.
// . . .
if ((int16)fpFoo == (int16)do_it)
{
// . . .
}
// . . .
}
|
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|