How to call pointer to function defined in typedef struct?

You have declared your counter_func member to be a pointer to an int, not a function pointer , while you have something resembling a function pointer declaration in your option values Here's what you want (assuming your return type is int ).

You have declared your counter_func member to be a pointer to an int, not a function pointer , while you have something resembling a function pointer declaration in your option values. Here's what you want (assuming your return type is int ) typedef struct OptionValueStruct{ char counter_nameOPTION_LINE_SIZE; int (*counter_func)(char*, char**): } OptionValueStruct_t; const OptionValueStruct_t option_values = { {"Counter1", parseCounter1}, {"Counter2", parseCounter2}, }; for(int I = 0; icounter_func(opt_name, opt_val); // don't know what you relly want to do with result further on.. }.

Thanks a lot for the answer – user399517 Aug 10 '10 at 5:00.

If you are compiling as C code (as your tag suggests), then you should change the type of option_values and option to OptionValueStruct_t. In C++, however, this is OK. Alternatively, you can eliminate the trailing _t from the custom type name.

Thanks for the answer. The type of option_values is already OptionValueStruct_t and the type of option is OptionValueStruct_t *. As I show in the original post.Do you mean I should use struct OptionValueStruct{...}, then use declaration struct OptionValueStruct option_value?

– user399517 Aug 10 '10 at 5:18 @lilili08 - at the time of writing this comment, the type of the two variables is const OptionValueStruct and not const OptionValueStruct_t. However, OptionValueStruct is the tag of the struct definition and not the name of the custom type (at the typedef statement). In C, a struct tag is NOT a new type.

In C++, though, it is. Now, the tag and the custom type name can be the same, so you can remove the _t characters from the typedef statement and have the newly defined type to be OptionValueStruct so you can use it in further variable declarations. – ysap Aug 10 '10 at 13:17 @lilili08 - If you are using the Visual C++, most probably the compilation is done as C++ code, so the compiler does not warn you about this.

You can change the Project Properties/Configuration Properties/C/C++/Advanced/Compile As to Compile as C code so you know for sure you are C compliant. – ysap Aug 10 '10 at 13:22.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions