c - This declaration has no storage or type specifier -


i have function:

void bs_gmm(img in_img,struct bs_gmm_var *gmm_ctxt,img *bg_msk,img *bg_img) 

in declaring variables like:

int num_models,num_features; float lr,update_factor; float deviation_thresh; int std_dev_int; 

the thing when trying define or use these variables — example:

num_models=gmm_ctxt->num_models; 

i getting 2 errors:

  1. regarding num_models:

    this declaration has no storage class or type specifier 
  2. and gmm_ctxt:

    gmm_ctxt undefined 

i know local variables default auto storage class , had specified type of variable; why type of error?

the function call main() in source file.

i know overseeing something. forgive me ignorance.

i had declared above mentioned function in header file , had included in both source files concerned.

the structure bs_gmm_var declared in header , had included in both source files concerned.the declaration goes follows

typedef struct bs_gmm_var { mean mean; std_dev std_dev; weight weight; classification_state classification_state; rank rank; rank_index rank_index;  int *match_array; float *prob_feature;  int num_models; float lr; float update_factor; float deviation_thresh; float assign_thresh,dying_thresh; float std_dev_int;  int intialize_state;  int width; int height; int num_features; int num_frames; }; 

then declared pointer above structure in main function.this pointer along structure sent following function.

the structure bs_gmm_var defined in function shown below:

void intialize_params(struct bs_gmm_var **gmm_ctxt,struct config_params bs_config_params) { struct bs_gmm_var *gmm_stats; int width=bs_config_params.width; int height=bs_config_params.height; int num_features=bs_config_params.num_features; int num_models=bs_config_params.num_models;  // allocate memroy whole structure gmm_stats = (bs_gmm_var *)malloc(sizeof(bs_gmm_var));  gmm_stats->mean=(float*)calloc(num_models*num_features*width*height,sizeof(float)); .     .in way have allocated memory other members(from mean prob_feature)     . gmm_stats->prob_feature=(float *)malloc(num_features*sizeof(float));   gmm_stats->num_models=bs_config_params.num_models; gmm_stats->lr= bs_config_params.lr; .in way other members(from num_models num_frames)are defined     .     gmm_stats->num_frames=bs_config_params.num_frames;  *gmm_ctxt = gmm_stats; } 

as can see defines structure bs_gmm_var through pointer gmm_stats. now,the pointer had sent above function address of structure(through pointer gmm_stats) defined.that pointer sending function:

void bs_gmm(img in_img,struct bs_gmm_var *gmm_ctxt,img *bg_msk,img *bg_img) 

both errors point struct bs_gmm_var being undefined. make sure include right header file, or define structure before function in code.

to confirm definition of structure, running code through preprocessor , looking @ output can help. gcc that's gcc -e ... using same compiler flags (except used linking).


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -