我有这样的类似的代码:功能ZAssert的隐含声明是无效的C99
ZAssert(modelURL, @"Failed to find model URL");
,但我得到这个错误:
implicit declaration of function ZAssert is invalid in C99
任何的你知道为什么还是哪能固定?
我有这样的类似的代码:功能ZAssert的隐含声明是无效的C99
ZAssert(modelURL, @"Failed to find model URL");
,但我得到这个错误:
implicit declaration of function ZAssert is invalid in C99
任何的你知道为什么还是哪能固定?
ZAssert
很可能是从某处或文件中复制的断言宏,现在不是您的代码库的一部分。它洛斯执行标准功能,这样你就可以简单地将其替换为:
NSAssert(modelURL, @"Failed to find model URL");
它将检查modelURL设置并抛出一个异常,如果不。
这里是ZAsset宏我发现了核心数据的书马库斯S. Zarra的
#ifdef DEBUG
#define MCRelease(x) [x release]
#define DLog(...) NSLog(@"%s(%p) %@", __PRETTY_FUNCTION__, self, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) {NSLog(@"%s(%p) %@", __PRETTY_FUNCTION__, self, [NSString stringWithFormat:__VA_ARGS__]);[[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__];}
#else
#define MCRelease(x) [x release], x = nil
#define DLog(...) do { } while (0)
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#define ALog(...) NSLog(@"%s(%p) %@", __PRETTY_FUNCTION__, self, [NSString stringWithFormat:__VA_ARGS__])
#endif
#define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)
有趣。对于在NSAssert上使用它的优点有一些解释是很好的。 –
看看这篇文章:http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ –
什么是ZAssert和你在哪里定义的呢? – Wain
这是我的问题。我不知道 – HelenaM
那么你为什么使用它?可能想阅读有关NSAssert – Wain