943,741 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 574
  • C++ RSS
Jan 19th, 2009
0

Help decoding line of typedef/struct combo

Expand Post »
I'm from a C background and need help with the following lines of code
C++ Syntax (Toggle Plain Text)
  1. struct IGame
  2. {
  3. // Summary
  4. // Entry function used to initialize a new IGame of a GameMod
  5. // Parameters
  6. // pGameFramework - a pointer to the game framework, from which a pointer of ISystem can be retrieved
  7. // Returns
  8. // A pointer to the newly created IGame implementation
  9. typedef IGame *(*TEntryFunction)(IGameFramework* pGameFramework);
  10. .
  11. .
  12. .
  13. .
Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d0pedup is offline Offline
14 posts
since Dec 2008
Jan 19th, 2009
0

Re: Help decoding line of typedef/struct combo

Mods: Couldn't edit so i added another post.

Why would any one want to typedef a simple struct with that maze of brackets and stars.

Could you please tell me the meaning of

C++ Syntax (Toggle Plain Text)
  1. typedef IGameFramework *(*TEntryFunction)();
The above to me, looked like a function call with no void argument.
Last edited by d0pedup; Jan 19th, 2009 at 7:02 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d0pedup is offline Offline
14 posts
since Dec 2008
Jan 19th, 2009
0

Re: Help decoding line of typedef/struct combo

TEntryFunction is a pointer to a function taking an IGameFramework pointer as a parameter and returning a pointer to an IGame
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007
Jan 19th, 2009
1

Re: Help decoding line of typedef/struct combo

Click to Expand / Collapse  Quote originally posted by d0pedup ...
Mods: Couldn't edit so i added another post.

Why would any one want to typedef a simple struct with that maze of brackets and stars.

Could you please tell me the meaning of

C++ Syntax (Toggle Plain Text)
  1. typedef IGameFramework *(*TEntryFunction)();
The above to me, looked like a function call with no void argument.
No, it is a type declaration of a function pointer:
TEntryFunction is a pointer to a function taking no argunemts and returning a IGameFramework pointer.
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007
Jan 19th, 2009
0

Re: Help decoding line of typedef/struct combo

Click to Expand / Collapse  Quote originally posted by jencas ...
No, it is a type declaration of a function pointer:
TEntryFunction is a pointer to a function taking no argunemts and returning a IGameFramework pointer.
Thank you, Thank you, Thank you you are a life saver.

So the return value would be of the type IgameFrameWork* and the return value would be assessable via a IgameFrameWork* pointer right..?
Last edited by d0pedup; Jan 19th, 2009 at 9:13 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d0pedup is offline Offline
14 posts
since Dec 2008
Jan 19th, 2009
0

Re: Help decoding line of typedef/struct combo

Needed to brush up on my function pointers, haven't really used them at all.
Found a neat article that might be of help
http://www.devx.com/tips/Tip/13829
Reputation Points: 10
Solved Threads: 0
Newbie Poster
d0pedup is offline Offline
14 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Efficiency of code used to read and write a delimited file
Next Thread in C++ Forum Timeline: DarkGDK macros





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC