• 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: "Alastair J.Houghton" <email@hidden>
  • Date: Mon, 11 Aug 2003 10:40:51 +0100

On Monday, August 11, 2003, at 12:11 am, Rob Kuilman wrote:

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

*That* doesn't do what you want, at least not in C. When you write "const char myVar = 0x10", in C, it represents a declaration of a global *variable* called "myVar" whose type is const char. This is *not* the same as in C++, where it means declare a *constant* called "myVar" of type char.

(The reason for the error is that in C, #including or #importing that file will declare the same global variable in every file you have #included or #imported it into, which will make the linker complain.)

If you want a similar effect in C/ObjC, you either need to use #define or enum.

Kind regards,

Alastair.
_______________________________________________
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: Graceful Crash
  • Next by Date: Re: Setting focus to text field in drawer
  • Previous by thread: Re: #Import problems
  • Next by thread: Application termination
  • Index(es):
    • Date
    • Thread