作者leondemon (狗狗)
看板MacDev
标题[问题] __attribute__
时间Sun Aug 18 16:12:25 2013
http://nshipster.com/__attribute__/
查了一下 在 GCC 时代
可以用__attribute__ 来检查传入的 parameter 是否为 null
来进行 compile time的提醒 例如:
extern void *my_memcpy (void *dest, const void *src, size_t len)
__attribute__((nonnull (1, 2)));
在现在的 LLVM 底下,有办法在 compile time 时对 Obj-C message 做一样的事情吗?
例如:
+ (void) managerWithIdentifier:(NSString*)identifier
__attribute__(nonnull (1));
这样写好像不会进行 compile time check...
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 223.142.142.72
1F:→ uranusjr:我觉得这不是 __attribute__ 的问题, 是 compiler 不会检 08/19 10:43
2F:→ uranusjr:查 Objective-C message... 08/19 10:44