Re: Why am I always getting the linker error: 'duplicate symbol'...?
Re: Why am I always getting the linker error: 'duplicate symbol'...?
- Subject: Re: Why am I always getting the linker error: 'duplicate symbol'...?
- From: Graham Cox <email@hidden>
- Date: Tue, 22 Sep 2009 11:04:18 +1000
On 22/09/2009, at 7:37 AM, Frederick C. Lee wrote:
So there's a lot of:
#define de2ra 1.74532925E-2 // Degrees to Radians.
#define pi 3.1415926535898 // Pi.
'pi' should already be defined by the fp/math lib, likely to greater
precision than above.
For de2ra, why not make it readable? Readable names cost nothing, I use:
#define DEGREES_TO_RADIANS( x ) ((x) * 0.0174532925199432958)
There's no mistaking what's going on in the code and it looks like a
function (though because I always use all upper case for macros, I can
see it's a macro anyway). Also, use brackets to make sure variables
and macro expansions are compartmentalised in such a way that compound
statements won't break them, introducing bugs that can be a devil to
spot.
Also, if you collect your macros together into one header file and
included where necessary, you can a) avoid writing them over and over
again (possibly making an error in one copy and causing a bug) and b)
lessen the problem you're having, where you end up with multiple
definitions colliding in the namespace.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden