Help decoding line of typedef/struct combo

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2008
Posts: 14
Reputation: d0pedup is an unknown quantity at this point 
Solved Threads: 0
d0pedup d0pedup is offline Offline
Newbie Poster

Help decoding line of typedef/struct combo

 
0
  #1
Jan 19th, 2009
I'm from a C background and need help with the following lines of code
  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 14
Reputation: d0pedup is an unknown quantity at this point 
Solved Threads: 0
d0pedup d0pedup is offline Offline
Newbie Poster

Re: Help decoding line of typedef/struct combo

 
0
  #2
Jan 19th, 2009
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

  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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: Help decoding line of typedef/struct combo

 
0
  #3
Jan 19th, 2009
TEntryFunction is a pointer to a function taking an IGameFramework pointer as a parameter and returning a pointer to an IGame
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: Help decoding line of typedef/struct combo

 
1
  #4
Jan 19th, 2009
Originally Posted by d0pedup View Post
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

  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.
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 14
Reputation: d0pedup is an unknown quantity at this point 
Solved Threads: 0
d0pedup d0pedup is offline Offline
Newbie Poster

Re: Help decoding line of typedef/struct combo

 
0
  #5
Jan 19th, 2009
Originally Posted by jencas View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 14
Reputation: d0pedup is an unknown quantity at this point 
Solved Threads: 0
d0pedup d0pedup is offline Offline
Newbie Poster

Re: Help decoding line of typedef/struct combo

 
0
  #6
Jan 19th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC