I am trying to pass a pointer by reference to a function and get that function to point my pointer at a structure that it finds.
char get_structure(STRUCTURE **ptr) { if(foundstructure) { *ptr = &theStructure; return 1; } return 0; }
This works how I expect it, but when I try and declare the function prototype in the header file:
char get_structure(STRUCTURE **ptr);
I always get a compiler error:
error C141: syntax error near '*', expected ')'
I don't get an error when this is a defined type like char, int or long, but I get the error when this is a pointer to a typedef that I have defined.
How can I declare this in my header file without an error?
Nathan
I mentioned in my post that although the example doesn't show it, struct.h does depend on function.h.
Circular dependencies are a design bug in your software. You must resolve that.
Generally speaking, when you can't decide whether "a.h" should include "b.h" or the other way round, that's a strong indication that your design is wrong, and you should really have only one header holding the combined content of both "a.h" and "b.h".
There is an enum that is declared in function.h that is used in STRUCTURE.
Then the definition of that enum should not be in "function.h". It belongs into "struct.h".
This kind of refactoring isn't possible right now, but rest assured I am aware that this file structure is inadequate. This isn't my project, it's an existing project that someone else created. I am avoiding the use of underscores before defined names now as well. Thanks for both those tips.