Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Nov 30, 2008 #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.


    The problem seem to have been that I didn't put semi-colons after the structure declarations. The prof mislead me into error. :grumpy:
    Last edited: Nov 30, 2008
  2. jcsd
  3. Nov 30, 2008 #2
    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.
  4. Dec 1, 2008 #3
    I needed to implement it by using tags rather than typedef. But thanks for the answer anyways.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook