Expand|Select|Wrap|Line Numbers
- #ifndef __MYHEADER__
- // basic includes
- // several defines
- // a few globals
- typedef struct
- {
- // data
- } foo_1;
- #if __cplusplus
- extern "C" {
- #endif
- // number of function prototypes for cpp source file
- #if __cplusplus
- }
- #endif
- // function prototypes for c source files
- #endif
Everything above compiles without errors or warnings. When I modify the above header to include another structure and a function prototype, I get compiler errors that strangely can be corrected using the "struct" keyword in the prototype and definition.
Expand|Select|Wrap|Line Numbers
- // modified header
- typedef struct
- {
- // data
- } foo_1;
- typedef struct
- {
- // data
- } foo_2;
- // new prototype
- void foo_bar(foo_2 *);
Expand|Select|Wrap|Line Numbers
- void foo_bar(foo_2 *bar)
- {
- // function def
- }
error C2143: syntax error : missing '{' before '*'
error C2059: syntax error : ')'
error C2059: syntax error : ';'
If I change the function to below, the errors mysteriously go away.
Expand|Select|Wrap|Line Numbers
- void foo_bar(struct foo_2 *);
- void foo_bar(struct foo_2 *bar)
- {
- //
- }
TIA