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

AI Thread Summary
The discussion revolves around an error encountered while compiling C code using GCC, specifically the message "error: two or more data types in declaration specifiers." The issue arose when attempting to define a function that returns a pointer to a structure. The root cause was identified as the omission of semicolons after the structure declarations, which is necessary for proper syntax in C. A suggestion was made to use `typedef` for the structure to simplify declarations, allowing for a more straightforward function definition. However, the original poster resolved the issue by correctly placing semicolons and opted to use tags instead of `typedef`.
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:
Technology 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.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top