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
You really will have to show a complete example demonstrating this. Without actually seeing how you defined STRUCTURE, there's no way anyone can help you. I'll venture a guess though: STRUCTURE is not actually a typedef, it's a #define, and therein lies your problem.
And don't be too embarrassed if, while composing that example. the cause of the problem jusmps out at you and you feel tempted to yell at yourself "How could you possibly overlook that, stupid!" That does happen to the best of us.
"That does happen to the best of us"
Indeed it does!
The process of creating an example which illustrates the problem - and only the problem - certainly can focus the mind and bring the solution to light all by itself!
See: www.8052.com/.../100837
Absolutely. See this thread - nobody believed me at the beginning, until it was confirmed and fixed...
http://www.keil.com/forum/15346/
http://www.keil.com/forum/19955/
View all questions in Keil forum