开发者

Size already defined

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 def开发者_如何学JAVAined?

I have only #imported Foundation/Foundation.h


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜