• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why am I always getting the linker error: 'duplicate symbol'...?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Why am I always getting the linker error: 'duplicate symbol'...? (From: "Frederick C. Lee" <email@hidden>)
 >Re: Why am I always getting the linker error: 'duplicate symbol'...? (From: Kyle Sluder <email@hidden>)
 >Re: Why am I always getting the linker error: 'duplicate symbol'...? (From: Jens Alfke <email@hidden>)
 >Re: Why am I always getting the linker error: 'duplicate symbol'...? (From: "Frederick C. Lee" <email@hidden>)
 >Re: Why am I always getting the linker error: 'duplicate symbol'...? (From: Jens Alfke <email@hidden>)
 >Re: Why am I always getting the linker error: 'duplicate symbol'...? (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Re: Oh notification, where are you?
  • Next by Date: Preferencepanel.xib file with an extra delegate object place inside
  • Previous by thread: Re: Why am I always getting the linker error: 'duplicate symbol'...?
  • Next by thread: Re: Why am I always getting the linker error: 'duplicate symbol'...?
  • Index(es):
    • Date
    • Thread