• 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: Objective-C++, class scope constants, name conflicts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C++, class scope constants, name conflicts


  • Subject: Re: Objective-C++, class scope constants, name conflicts
  • From: Tommy Nordgren <email@hidden>
  • Date: Sat, 11 Feb 2006 20:28:59 +0100


On Feb 10, 2006, at 12:23 AM, Scott Ribe wrote:

What I need is essentially a constant integer value with class scope. In C++
I got used to the class enum trick, but I don't know what to do in an
Objective-C class.


I tried "static const int controlSetCnt = 0;" inside the @interface, but
this causes the compiler to crash. So I moved it outside the @interface, and



Either declare it as static const int inside the IMPLEMENTATION file,
or, since you're using it in objective c++, define it inside a NAMESPACE in the header
file.
it appeared to work fine. However, as soon as I have another class with the
same need and use the same technique, I get "error: redefinition of 'const
int controlSetCnt'". This is because there is one implementation file (my
application delegate) that has to know enough about both these classes to
instantiate them. The constant needs to be in the header file, because it
defines the size of an array member of the class:


 BloodPressure_ControlGroup * bpControls[controlSetCnt];

So my question is: do I really have to avoid this kind of name conflict by
naming a simple constant, which is only used in one class, and not exported
to the linker, with an awful name like:
controlSetCountForClinicExamWindowController


Well, amusingly enough, there is actually an appropriate C++ namespace for
each, so my other option is foo::bar::controlSetCnt...


--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40chello.se


This email sent to email@hidden

------------------------------------- This sig is dedicated to the advancement of Nuclear Power Tommy Nordgren email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Objective-C++, class scope constants, name conflicts
      • From: Scott Ribe <email@hidden>
References: 
 >Objective-C++, class scope constants, name conflicts (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: Modifying Info.plist at runtime
  • Next by Date: Re: frontmost document window (of all running apps)?
  • Previous by thread: Re: Objective-C++, class scope constants, name conflicts
  • Next by thread: Re: Objective-C++, class scope constants, name conflicts
  • Index(es):
    • Date
    • Thread