• 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: "Frederick C. Lee" <email@hidden>
  • Date: Mon, 21 Sep 2009 14:37:20 -0700

This is for an iPhone application, using ObjC code with access to C-level
functions and primitive data types.The original primitive types are either
double, float, sci notiation(E) or unsigned int.
So there's a lot of:
#define de2ra     1.74532925E-2       // Degrees to Radians.
#define pi           3.1415926535898     // Pi.

I had thought using static const vs #define would be more-efficient for
computing & storage...
... so I've read.

But if #define is efficient enough, it's easier just to keep the #define
statements.

Ric.



On Mon, Sep 21, 2009 at 2:27 PM, Jens Alfke <email@hidden> wrote:

>
> On Sep 21, 2009, at 2:15 PM, Frederick C. Lee wrote:
>
>  I'm assuming 'const <datatype>' is better then the compiler directive
>> '#define', due to the use of the compiler
>> for more-efficient code.   Hence the attempt.
>>
>
> It depends. In C, a const variable of a primitive type like an integer is
> less efficient than a #define. The problem is that it ends up being treated
> as a regular global variable (except its value can't be changed). In C++,
> though, const primitives are optimized away just as a #define would be, and
> can be declared without an 'extern' in a header.
>
> (If you want, you can get the C++ semantics by using Objective-C++, i.e.
> changing the suffix of your source files to .mm.)
>
> —Jens
_______________________________________________

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

  • Follow-Ups:
    • Re: Why am I always getting the linker error: 'duplicate symbol'...?
      • From: Graham Cox <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>)

  • Prev by Date: Re: Architecture for concurrent network client
  • Next by Date: Re: Why am I always getting the linker error: 'duplicate symbol'...?
  • 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