C Enumerated Types / Function Pointer Errors
I have the following C code:
Code:
enum func_err_code {FUNC1, FUNC2, FUNC3}; Pertaining to the first function: Code:
error_handler.h:17: error: expected ')' before 'int' Code:
error_handler.h:22 error: expected ')' before 'function_code' Code:
error_handler.h:24 warning: 'enum func_err_code' declared inside parameter list |
Try using a typedef for your function pointers. It is good practice anyway.
|
Quote:
(Linuxquestions wants more characters. Linuxquestions wants more characters.) |
Quote:
Quigi -- Checked the typo and that was a forum post error on my part. I'm still getting the same errors as stated above. Thanks. |
Hi Centinul,
Your problem was omitting "enum" in C. (Your original code is correct C++, I compiled it without a complaint. I'd switch the language :) ) The following modified error_handler.h compiles fine as C: Code:
enum func_err_code {FUNC1, FUNC2, FUNC3}; BTW, you can just compile error_handler.h (and not the .c file of similar name) to trim down the problem for us. And the line numbers where you report errors seem wrong for a file of 7 lines. |
Quote:
Quote:
Quote:
::EDIT:: Interestingly enough I tried putting the enum keywords back and it worked. I'm not sure why it failed the first time. Thanks for all the help. |
Example:
Code:
typedef int (*F)(int, char *, char * ); It's just like a switch where you call differnet functions depending on the argument to switch(). |
|
Quote:
Code:
// type f_err_code is short for "enum func_err_code" |
All times are GMT -5. The time now is 09:13 PM. |