|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
definition of FUNCPTR
Hello, I am looking at the WPIlib code and have a question
in task.h line 39 I found the variable type 'FUNCPTR' and I didn't found the definition of it in the project, do you know what is the definition of it? thanks a lot, team 1937. |
|
#2
|
||||
|
||||
|
Re: definition of FUNCPTR
I am not certain which file it is defined in but what it is is a function pointer. It allows you to pass around a reference to functions of the same signature (same return type and parameter types). Function pointers are often used for callbacks where you will provide some function a pointer to a function they should call when some event happens. Wikipedia has a pretty good overview in their Function pointer article.
|
|
#3
|
|||
|
|||
|
Re: definition of FUNCPTR
Hello, I read what you wrote and I have a question
How can I know the return type of the function and the type of the function's arguments? thank you, Team 1937 |
|
#4
|
||||
|
||||
|
Re: definition of FUNCPTR
Code:
typedef int (*FUNCPTR)(...); |
|
#5
|
|||||
|
|||||
|
Re: definition of FUNCPTR
Soo... a function pointer holds the address of a function, it's arguments and return type?
|
|
#6
|
||||
|
||||
|
Re: definition of FUNCPTR
Close, it is just the address of the function. You define the types for the parameters and return and the compiler will setup the function call correctly for you. It will also (if it can) double check that you are calling the function with the correct signature (signature being types of return and parameters) to prevent simple mistakes.
|
|
#7
|
|||
|
|||
|
Re: definition of FUNCPTR
Can't the int be typecast as a float, etc.?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pwm definition problems | Anton | Programming | 4 | 02-02-2005 13:01 |
| Its-Definition Please | archiver | 2000 | 4 | 24-06-2002 00:08 |
| Definition of aluminum extrusion...? | kangarue23 | Technical Discussion | 4 | 25-01-2002 16:53 |