• 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: #Import problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #Import problems


  • Subject: Re: #Import problems
  • From: Pete Yandell <email@hidden>
  • Date: Mon, 11 Aug 2003 13:39:55 +1000

The compiler is complaining because you're effectively trying to declare multiple copies of myVar in different .c files, not because you're including the declaration more than once in a given file.

What you need to do is declare the variable somewhere in a single .c file as:

const char myVar = 0x10;

then in your .h file have:

extern const char myVar;

Note that this is not specific to using #import. You'd have to do it exactly the same way using #include.

Pete Yandell
http://pete.yandell.com/

On Monday, August 11, 2003, at 09:11 AM, Rob Kuilman wrote:

Hey all!

I've been working on an Application that, well, inevitably includes files. back in the 'old' days, one would #ifndef #define #endif a header file to make sure it would be included only once. However, the Cocoa manual ensured me, that i could #import "filename.h" without having to place these guards.

So i have a header file, which declares some global values for me, and i have to include this file in two files, that include eachother (this is where the #import guards came into work) but it gave me the 'multiple definitions of...' error.

note: the header file i want to include is just plain C, some
const char myVar = 0x10
et al.

Someone knows what to do ?

Thanks in advace

Robert K.

-----------------------------{ Official Cocoa Newbie! }-----------------------------
web: http://halfduplex.net/
email: email@hidden
_______________________________________________
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.
_______________________________________________
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.

References: 
 >#Import problems (From: Rob Kuilman <email@hidden>)

  • Prev by Date: Re: Documents & Controllers
  • Next by Date: Re: Setting focus to text field in drawer
  • Previous by thread: #Import problems
  • Next by thread: Re: #Import problems
  • Index(es):
    • Date
    • Thread