Objective-C iddiası için NSAssert makrosunu kullanıyorum ve bunu yapmanın normal yolu. Ancak C işlevlerinde çalışmaz. Bunun için ne kullanmalıyım?C'deki normal iddia yöntemi nedir?
5
A
cevap
7
NSCAssert()
(ve ayrıca NSCAssert1()
... up dahil)
11
#include <assert.h>
...
assert(<expression>);
4
void assert(int expression); If expression evaluates to 0 (false), then the expression, source code filename, and line number are sent to the standard error, and then calls the abort function. If the identifier NDEBUG ("no debug") is defined with #define NDEBUG then the macro assert does nothing.
Örnek:
assert(x != 0);
not: 012 için assert.h
Ayrıca, http://vgable.com/blog/2008/12/04/nsassert-considered-harmful için "assert (x! = 0 &&", ne hey? ") . –