2

I was messing with my Objective-C++ namespace today.

I found that Handle, Size and Duration are already defined in ObjC++. What are they defined to be and where are they defined?

I have only #imported Foundation/Foundation.h

2
  • Can you show us the list of includes that you've used? May 18, 2010 at 3:15
  • listed imports as you requested.
    – John Smith
    May 18, 2010 at 3:19

2 Answers 2

6

MacTypes.h

typedef char *                          Ptr;
typedef Ptr *                           Handle;
typedef long                            Size;
typedef SInt32                          Duration;

These all predate Carbon. They having nothing to do with Cocoa even though they fill up the namespace.

2

You can Command-double-click on a symbol in Xcode to see where it's defined, or use "Open Quickly" (Command-Shift-D) and type a symbol name. Handle, Size and Duration are in the CoreServices framework, for example.

To avoid conflicts, you should always use a unique prefix (typically your initials or a shortened version of your project's name) in your global Objective-C names. Take a look at the answers to this question which link to some Objective-C style guides.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.