Jump to content
Sign in to follow this  
Guest HC001ST - Stick

Question about redefinitions in FS9Gauge.h

Recommended Posts

Guest HC001ST - Stick

Arne,Not sure if you are the one that made this change, but I'm guessing you are, and I'm a little curious about it.From gauge.h we have:typedef (*GAUGE_KEY_EVENT_HANDLER) (ID32 event, UINT32 evdata, PVOID userdata);which right off the bat I'm thinking MS left off a return type to the function pointer, unless GAUGE_KEY_EVENT_HANDLER can explain this. I search for it's definition, and find none!I see that you changed it to:/*typedef void FSAPI GAUGE_CALLBACK( PGAUGEHDR pgauge, // Some comments you add? SINT32 service_id, UINT32 extra_data );typedef GAUGE_CALLBACK *PGAUGE_CALLBACK;*///typedef (*GAUGE_KEY_EVENT_HANDLER)// (ID32 event, UINT32 evdata, PVOID userdata);typedef void VGAUGE_KEY_EVENT_HANDLER( ID32 event, UINT32 evdata, PVOID userdata);typedef VGAUGE_KEY_EVENT_HANDLER *GAUGE_KEY_EVENT_HANDLER;/*typedef void FSAPI QUERY_ROUTINE( void );*/What a mouthful!Anyway, my assumption is that you were trying to clear up what the code did, and maybe make it more portable.My question is: since there was not return type in the original typedef, does this make it void? And where is GAUGE_KEY_EVENT_HANDLER 'S definition???Patrick

Share this post


Link to post
Share on other sites
Guest bartels

It wasn't for cleanup, the missing "void" declaration meant simply it was broken. C compiling might accept this, but at least C++ will fight tooth and nail against improper function declarations. If you use one or two lines for declaration ist just a matter of taste.As for the key handler definition, you can write it for yourself as long as you use the same function prototype you can do what you want in the function, just like all other callback functions in the gauges. This one is called when a key event is triggered in FS, event is the key event, evdata is the optional data, userdata is a pointer to data you can add when you register with register_key_event_handler e.g. the pgauge pointer.

Share this post


Link to post
Share on other sites
Guest HC001ST - Stick

>It wasn't for cleanup, the missing "void" declaration meant>simply it was broken. C compiling might accept this, but at>least C++ will fight tooth and nail against improper function>declarations. Awesome! I can't believe I finally understand this code. =)I thought it was broken. Learning this stuff is best accomplished by not looking at MS's broken code first.>If you use one or two lines for declaration ist>just a matter of taste.Yes, I split it only for posting. Your original style was fine.>As for the key handler definition, you can write it for>yourself as long as you use the same function prototype you>can do what you want in the function, just like all other>callback functions in the gauges. This one is called when a>key event is triggered in FS, event is the key event, evdata>is the optional data, userdata is a pointer to data you can>add when you register with register_key_event_handler e.g. the>pgauge pointer. So really, that whole thing was really just a prototype?I'm still confused though, that identifier is all CAPS suggesting it is defined somewhere, but it is not.thanks Arne

Share this post


Link to post
Share on other sites
Guest HC001ST - Stick

now that i think about it, in C it would default to a return type of int.Patrick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...