Trying to compile a function with pointer to structure as return value with gcc

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
Werg22
Messages
1,431
Reaction score
1
I get an error with gcc "error: two or more data types in declaration specifiers" when trying to compile something of the form:

struct tag *function (...) { ...}

Apparently it won't let me create functions with return values pointers to structures. I know that it's perfectly valid code, so I don't know why it's not letting me do this. Any help on this would be appreciated.

edit:

The problem seem to have been that I didn't put semi-colons after the structure declarations. The prof mislead me into error.
 
Last edited:
Physics news on Phys.org
Yes, you would need a semicolon after the struct definition statement.
It would also help if you could post an abridged code the demonstrates the problem, and the associated error codes.
Try typedef before your structure definition, so you can declare directly
tag *function(...){...}
just like any other type, if that solves your problem.
 
I needed to implement it by using tags rather than typedef. But thanks for the answer anyways.