Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann
Okay, I tried searching, and didn't find anything pertinent...

How do I create a property for a class named private and not have the 
Objective-C++ compiler trip on it?

Here's what I first tried:

@property(assign,getter=isPrivate) BOOL private;

That @property declaration works just fine when compiling Objective-C code, but 
when the header is imported into Objective-C++ code, I get the following error 
twice:
error: expected unqualified-id before 'private'

I know the word private is used as a keyword in C++ to mark the private 
section of a class. So I tried rephrasing that property declaration to try and 
get the compiler to treat the word private as a property name and not as a 
C++ keyword. I thought this might work:

#ifdef __cplusplus
extern C {
#endif
@property(assign,getter=isPrivate) BOOL private;
#ifdef __cplusplus
}
#endif

But I still get a compiler error:
error: misplaced '@property' Objective-C++ construct

I'm using GCC 4.2 as the compiler. At this point it's not a big deal, because I 
can still use old-school property declarations, but it would be nice to know 
how to fix this problem (if possible)...

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Ricky Sharp

On Sep 28, 2010, at 6:19 PM, Nick Zitzmann wrote:

 Okay, I tried searching, and didn't find anything pertinent...
 
 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?
 
 Here's what I first tried:
 
 @property(assign,getter=isPrivate) BOOL private;
 
 That @property declaration works just fine when compiling Objective-C code, 
 but when the header is imported into Objective-C++ code, I get the following 
 error twice:
 error: expected unqualified-id before 'private'
 
 I know the word private is used as a keyword in C++ to mark the private 
 section of a class. So I tried rephrasing that property declaration to try 
 and get the compiler to treat the word private as a property name and not 
 as a C++ keyword. I thought this might work:


Why do you need to use the exact name of private?  You should never name 
things using reserved words.

How about simply adding a suffix or prefix?

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann

On Sep 28, 2010, at 5:51 PM, Ricky Sharp wrote:

 Why do you need to use the exact name of private?  

Because the object in question has a private state.

 You should never name things using reserved words.

But it's not a reserved word in Objective-C. @private is, private is not.

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Greg Parker
On Sep 28, 2010, at 4:19 PM, Nick Zitzmann wrote:
 Okay, I tried searching, and didn't find anything pertinent...
 
 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?

You can't. C++ reserved words are unavailable for use in Objective-C++. The 
only exception is in method names.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann

On Sep 28, 2010, at 6:07 PM, Greg Parker wrote:

 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?
 
 You can't. C++ reserved words are unavailable for use in Objective-C++. The 
 only exception is in method names.

Okay, thank you for clarifying that.

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Dave Carrigan
On Sep 28, 2010, at 4:57 PM, Nick Zitzmann wrote:
 
 On Sep 28, 2010, at 5:51 PM, Ricky Sharp wrote:
 
 Why do you need to use the exact name of private?  
 
 Because the object in question has a private state.
 
 You should never name things using reserved words.
 
 But it's not a reserved word in Objective-C. @private is, private is not.


Objective-C != Objective-C++

And it is a reserved word in Objective-C++.

In addition, even if it were just Objective-C, it is still not generally good 
practice to use C++ reserved words (class, private, etc.). 

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Rob Ross

On Sep 28, 2010, at 4:19 PM, Nick Zitzmann wrote:

 @property(assign,getter=isPrivate) BOOL private;

What about trying

@property(assign) BOOL isPrivate;

?

Rob
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Nick Zitzmann

On Sep 28, 2010, at 6:10 PM, Dave Carrigan wrote:

 Objective-C != Objective-C++
 
 And it is a reserved word in Objective-C++.

I know; I was just wondering if there was a workaround that would tell the 
ObjC++ compiler to treat the property as if it was in ObjC (where it is not a 
reserved word) and not ObjC++. But it's already been confirmed that there 
isn't, so now we know.

Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com