Re: Objective-C++, class scope constants, name conflicts
Re: Objective-C++, class scope constants, name conflicts
- Subject: Re: Objective-C++, class scope constants, name conflicts
- From: Scott Ribe <email@hidden>
- Date: Thu, 09 Feb 2006 17:17:02 -0700
- Thread-topic: Objective-C++, class scope constants, name conflicts
> Was static const no good? i.e.
>
> class Foo
> {
> static const int value = 123;
> void Fn();
> };
That wasn't allowed in C++ for quite a while. I think it was ISO C++ that
added it? Thus my comment about getting used to the enum trick.
Anyway, my need is not for that but for:
@interface Foo
static const int val = 123;
@end
Which causes the compiler to crash. I'm guessing it's not legal Objective-C,
because if it were surely gcc regression tests would have caught such a bug.
I suppose I could be accused of being retarded for only just now thinking to
try:
@interface Foo
enum { kControlSetCnt = 6 };
@end
That works. On some level it's annoying to have to go back to using an
anonymous enum to fake an int constant (and of course doesn't help at all
for a class-scope float-point constant), but it's cleaner than the
alternatives.
Perhaps an Objective-C enhancement request is in order?
--
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:
This email sent to email@hidden