Re: Removing NSLog & NSAssert for deployment
Re: Removing NSLog & NSAssert for deployment
- Subject: Re: Removing NSLog & NSAssert for deployment
- From: Jim Correia <email@hidden>
- Date: Thu, 7 Feb 2002 17:42:07 -0500
On Thursday, February 7, 2002, at 04:56 PM, Bill Cheeseman wrote:
This went right over my head. Can you elucidate?
1. As to NSAssert: WHERE and HOW do I define NS_BLOCK_ASSERTIONS? That
is,
is it defined automatically by Project Builder when I choose the
Deployment
build style, or one of the optimization levels? Or should I define it
myself
in the build settings for the deployment target? Or do I have to define
it
in each code file? And is defining it enough to magically suppress
NSAssert
calls in my deployment build, or must I also wrap all my NSAssert calls
in
#if defined(NS_BLOCK_ASSERTIONS) ... #endif? Or #ifdef
NS_BLOCK_ASSERTIONS
... #endif?
[snip]
I need a short walk through an example, here.
Define it in the build settings for that target (or a build style
applied to that target).
For a target it goes in other compiler settings. I is
-DNS_BLOCK_ASSERTIONS=1
for a build style it needs to be assigned to OTHER_CFLAGS. Make sure
the middle column is +=. You'll have to rebuild clean. Since this
value is different from that in the precompiled header you should get a
warning as such, and the build will be slower.
2. As to NSLog, where can I read about "variadic macros"? Which
/Developer
docs are you talking about?
See the other posts on the subject. variadic macros appear not to work
with the default pre-processor.
I wanted to do something like (where DEBUG is defined the same way as
the preprocessor value above)
#if DEBUG
#define DLOG(yadda yadda yadda) NSLog(yadda yadda yadda)
#else
#define DLOG(yadda yadda yadda) // nothing
#endif
So unless you are willing to live with the other preprocessor you can
make in inline function which logs in debug builds and does nothing in
production builds (it will simply call through to NSLog) and use it
instead of NSLog in *your* source code where you don't want things
logged in production builds.
#if DEBUG
inline void DLOG(NSString *format, ...)
{
va_list args;
va_start(args, format);
NSLogv(format, args);
va_end(args);
}
#else
inline void DLOG(NSString *format, ...){}
#endif
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.