Re: NS_INLINE and obj = nil;?

2010-01-04 Thread Andy Lee
On Jan 3, 2010, at 5:26 PM, Scott Ribe wrote: Easily fixed: #define GDRelease(x) [(x) release], (x) = nil, (void)0 Not really a good fix; compiler error is preferable to tweaking your macro to allow compilation of nonsense ;-) Actually this causes a compiler error if you try if

Re: NS_INLINE and obj = nil;?

2010-01-03 Thread Greg Parker
On Jan 2, 2010, at 9:30 AM, Alexander Spohr wrote: I put a , not a ; between the statements. So at least my last example would work - had I just left the last ; out of it: #define GDRelease(x) [(x) release], (x) = nil expands to: if(x) [(x) release], (x) = nil; else foo(x); But

Re: NS_INLINE and obj = nil;?

2010-01-03 Thread Dave G
2010/1/4 Greg Parker gpar...@apple.com: On Jan 2, 2010, at 9:30 AM, Alexander Spohr wrote: I put a , not a ; between the statements. So at least my last example would work - had I just left the last ; out of it: #define GDRelease(x) [(x) release], (x) = nil expands to: if(x)   [(x)

Re: NS_INLINE and obj = nil;?

2010-01-03 Thread Scott Ribe
Easily fixed: #define GDRelease(x) [(x) release], (x) = nil, (void)0 Not really a good fix; compiler error is preferable to tweaking your macro to allow compilation of nonsense ;-) -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice

Re: NS_INLINE and obj = nil;?

2010-01-02 Thread Alexander Spohr
Am 02.01.2010 um 05:09 schrieb Stephen J. Butler: If you really wanted a macro, it would look like this: #define GDRelease(x) do { [(x) release]; (x) = nil; } while (0) What is the do while good for? Would this not work as well: #define GDRelease(x) { [(x) release]; (x) = nil; } Or even

Re: NS_INLINE and obj = nil;?

2010-01-02 Thread David Duncan
On Jan 2, 2010, at 6:29 AM, Alexander Spohr wrote: What is the do while good for? It lets you reliably write constructs like: if(condition) MyMacro(foo); -- David Duncan Apple DTS Animation and Printing ___ Cocoa-dev mailing list

Re: NS_INLINE and obj = nil;?

2010-01-02 Thread Clark Cox
On Sat, Jan 2, 2010 at 6:29 AM, Alexander Spohr a...@freeport.de wrote: Am 02.01.2010 um 05:09 schrieb Stephen J. Butler: If you really wanted a macro, it would look like this: #define GDRelease(x) do { [(x) release]; (x) = nil; } while (0) What is the do while good for? Would this not

Re: NS_INLINE and obj = nil;?

2010-01-02 Thread Alexander Spohr
Am 02.01.2010 um 17:28 schrieb Clark Cox: On Sat, Jan 2, 2010 at 6:29 AM, Alexander Spohr a...@freeport.de wrote: Would this not work as well: #define GDRelease(x) { [(x) release]; (x) = nil; } Or even this: #define GDRelease(x) [(x) release], (x) = nil; No, neither would work as

NS_INLINE and obj = nil;?

2010-01-01 Thread aaron smith
Hey All, quick question, I wrote a simple macro to make memory cleanup a bit easier, but I ran into something I'm not sure why is happening.. here's the macro: NS_INLINE void GDRelease(id obj) { [obj release]; obj=nil; } I use it like: - (void) dealloc {

Re: NS_INLINE and obj = nil;?

2010-01-01 Thread Stephen J. Butler
On Fri, Jan 1, 2010 at 10:01 PM, aaron smith beingthexemplaryli...@gmail.com wrote: Hey All, quick question, I wrote a simple macro to make memory cleanup a bit easier, but I ran into something I'm not sure why is happening.. here's the macro: NS_INLINE void GDRelease(id obj) {