Structure Initialization Unmatched variables

Go To


I am confused as to what this is doing:

#define AIR_LP 1

tw_lptype airport_lps[] = {
    AIR_LP, sizeof(Airport_State),
    (init_f) Airport_StartUp,
    (event_f) Airport_EventHandler,
    (revent_f) Airport_RC_EventHandler,
    (final_f) Airport_Statistics_CollectStats,
    (statecp_f) NULL
  { 0 },


struct tw_lptype
  init_f init;
  event_f event;
  revent_f revent;
  final_f final;
  map_f map;
  size_t state_sz;

I guess I am getting confused by the first two variables in the structure declaration AIR_LP and sizeof(Airport_state), I understand what all the rest is doing, so if someone can just give me some info as to what those two parts are going to that would be great.

2012-04-03 23:22
by csteifel
There is also an extra field at the end of the structure that is not initialized, and the next to last field is initialized to the wrong type. Is there any conditional compiling (i.e. #ifdef similar) around the definition of the structure - Some programmer dude 2012-04-04 06:03


It's difficult to answer your question without knowing the types involved. The problem you are having is that your initialization has 7 attributes to the structure when your structure has 6. The AIR_LP, sizeof(Airport_State), are separate elements unlike the rest of the initialization which consists of a type cast followed by a value.

2012-04-03 23:29
by Lou
Aye, but its not a problem, nor is it my code, it works perfectly fine just like this which is why its confusing m - csteifel 2012-04-03 23:49
Then you got me.. - Lou 2012-04-04 05:13