Jump to content
  • Advertisement
Sign in to follow this  
Timptation

struct declaration c/c++/obj-c

This topic is 2926 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the difference between:

struct MyStruct
{
...
};

and

typedef struct
{
...
} MyStruct;

The second allows my obj-c code to compile, and the first does not.

Share this post


Link to post
Share on other sites
Advertisement
The first is C++ syntax. The latter is C syntax. obj-c is a superset of C, not C++. However, if you want XCode to compile the former, rename your file to .mm instead of .m

That will allow you to reference and use C++ code. Just remember when you start getting weird compile errors that any file that includes a header with C++ syntax must also have the .mm filename. When I'm starting a new iPhone project, the first thing I do is just rename everything to be .mm. That way I don't have to worry about it :)

-me

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!