Object Definition
-
typedef UpdateHandler* UpdateHandlerPtr;
I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do?typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
-
typedef UpdateHandler* UpdateHandlerPtr;
I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do?typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
Jay03 wrote:
typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
That is the definition of UpdateHandler. This syntax is creating a function pointer. For more information, look up callback functions and function pointers.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Jay03 wrote:
typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
That is the definition of UpdateHandler. This syntax is creating a function pointer. For more information, look up callback functions and function pointers.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Isn't it a declaration? It's interesting - I wonder how the compiler parsed out the fact that it is not typedef'ing void?
A cynic is a man who, when he smells flowers, looks around for a coffin.
-H.L. MenckenThe problem is that function pointer syntax is bizarre (sorry guys it is). In this example you are typdefing a function pointer that returns void and two parameters (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&) to the name UpdateHandler. It does look wierd, but it works. On those occasions I need function pointers, I always have to look at an example because I can never quite remember it.
-
typedef UpdateHandler* UpdateHandlerPtr;
I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do?typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
I Suggest you read the Book by Brian W. Kernighan & Dennis M. Ricthie: the C Programming Language This book is Much maligned, but actually very good! It spells out the Syntax and methods of the C Language, without going into the legalities, like the ANSI standard does! On page 122 of my copy it gives paragraph 5.12- Complicated Declarations. It explains there in lucid details how to read your declaration, and gives the code for a simple program which takes a declaration, and translates it back into 'english' Success
LateNightsInNewry
-
The problem is that function pointer syntax is bizarre (sorry guys it is). In this example you are typdefing a function pointer that returns void and two parameters (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&) to the name UpdateHandler. It does look wierd, but it works. On those occasions I need function pointers, I always have to look at an example because I can never quite remember it.
-
The problem is that function pointer syntax is bizarre (sorry guys it is). In this example you are typdefing a function pointer that returns void and two parameters (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&) to the name UpdateHandler. It does look wierd, but it works. On those occasions I need function pointers, I always have to look at an example because I can never quite remember it.
Thanks, This brought some clarity on function pointer to me and i think this is a better of doing it. I hope this method is supported in most all compilers. typedef int FunctPtr(int,int); .... main { FunctPtr *fp = somefunction; //This declaration is clearer that fp variable is a pointer. fp(...); } typedef int (*FuctPtr1)(int, int); //sometimes looks confusing as what is happening. and FuctPtr1 c = somefunc; -- modified at 4:03 Thursday 17th August, 2006 -- modified at 4:04 Thursday 17th August, 2006
-Prakash
-
And it's going to show up on one of the awful employment tests that they give us.
A cynic is a man who, when he smells flowers, looks around for a coffin.
-H.L. MenckenFrom experience, I can tell you that it will if you ever apply to Amazon.com. Just an FYI.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Jay03 wrote:
typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
That is the definition of UpdateHandler. This syntax is creating a function pointer. For more information, look up callback functions and function pointers.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Zac Howland wrote:
This syntax is creating a function pointer
Won't it be typedef void UpdateHandlerPtr (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&); or typedef void (UpdateHandler*) (ObjectRootPtr,const RTI::AttributeHandleValuePairSet&);
typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
is syntaxically equivalent to writingtypedef void (*UpdateHandlerPtr)(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac