Jump to content
  • Advertisement
Sign in to follow this  
ms75214

NSRect

This topic is 2497 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

Why is NSRect defined this way?

typedef struct _NSRect
{
NSPoint origin;
NSSize size;
} NSRect;


Why not?

struct NSRect
{
NSPoint origin;
NSSize size;
};

Share this post


Link to post
Share on other sites
Advertisement
It's a C thing. In C the names of struct types live in a separate namespace from other symbols, so if you define a struct A you always need to say struct A when using A. This way the typedef puts the name of the type in the same namespace as everything else.

Share this post


Link to post
Share on other sites
C compatibility. In standard C you can not (could not at the time?) use structs directly as a type like:

NSRect myRect

But had to write:

struct NSRect myRect

So the typedef helps you type less.

Edit: Ninja'd by SiCrane and his explanation is probrably more technically correct...

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!