On 2 Apr '08, at 5:03 PM, Richard Somers wrote:

The NSAssert complies out in the release configuration by using the preprocessor macro NS_BLOCK_ASSERTIONS. This results in a warning: unused variable "error". Do most programmers turn off the unused variable warnings or do something else to get this to work.

I don't think most people use NS_BLOCK_ASSERTIONS; instead they leave the assertion checks in the shipping product. Every Cocoa app (and framework) that Apple ships has assertions enabled, as far as I know.

This does add a little bit of overhead (code size more than performance.) But it makes the app more resilient to unexpected failures — a bug is more likely to result in an error alert than a crash. It also makes bugs reported by users more informative, as you can glean a lot more information from an exception message than you can from a crash log. (Especially if you add a bit of code to display exception backtraces.)

But I'm not going to tell you not to compile the assertions out; it's a matter of individual judgment. I seem to recall a pragma or macro that can be used to tell the compiler "I know this variable is unused, don't complain about it", though I don't remember the details...

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to