structure within a structure in C
I've been asked to transfer a bit of code from C++ to C. But am having a small bit of trouble with a .h file. Basically it calls a structure from a structure.
so I have
A_STRUCTURE location; <- problem line
When I build I get the follwing error
test.h:37: error: syntax error before A_STRUCTURE
I'm sure I could move A_STRUCTURE to another .h file, but other that doing that can I decalre a structure calling a structure in a header file in C? (If that makes sense :s )
In C, you either have to use "struct A_STRUCTURE" whenever you reference that type, or use the typedef idiom:
You either have to add struct before A_ in definiton of B_
Thanks :D all worked went for struct. All my years programming C and I never knew that. It's nice to learn something so usefull but so easy.
|All times are GMT -5. The time now is 08:42 AM.|