View previous topic :: View next topic |
Author |
Message |
[email protected]
Joined: 05 May 2006 Posts: 2
|
Function Pointers? |
Posted: Fri May 05, 2006 4:01 pm |
|
|
Does CCS allow the use of function pointers? For example, I want to pass a function pointer in another function like so (standard C):
unsigned char RegisterMessageDelegate(int (*MessageDelegate)(unsigned char *,unsigned short));
The compiler will not allow this. Is there another way of using function pointers with this compiler?
Thanks,
ELi |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
|
[email protected]
Joined: 05 May 2006 Posts: 2
|
No, not pointers to variables, pointers to Function |
Posted: Mon May 08, 2006 7:26 am |
|
|
QSORT Only appears to be a standard pointer (for memory/variables). What I need is support for pointers to Functions.
-ELi |
|
|
Ttelmah Guest
|
|
Posted: Mon May 08, 2006 7:38 am |
|
|
No, QSORT, uses pointers to functions, not just to values. There is a function 'ascending', and a function 'descending', and these are passed to the qsort function as the 'compare' item. Look again.
Best Wishes |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon May 08, 2006 7:59 am |
|
|
You can also use the search feature to find your answers. Here is a snippet from an old post
Code: |
// Typedef for our function pointer
typedef int (*pFunc)(void);
int myfunction(void)
{
return (1);
}
void main()
{
int i;
pFunc ptrtofunc;
// Dummy initialization to keep the compiler from complaining
ptrtofunc = myfunction;
// Call the function
i=(*ptrtofunc)();
while( TRUE )
{
}
}
|
|
|
|
|