• 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
Declaring a property named "private" and ObjC++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Declaring a property named "private" and ObjC++


  • Subject: Declaring a property named "private" and ObjC++
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 28 Sep 2010 17:19:26 -0600

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Declaring a property named "private" and ObjC++
      • From: Rob Ross <email@hidden>
    • Re: Declaring a property named "private" and ObjC++
      • From: Greg Parker <email@hidden>
    • Re: Declaring a property named "private" and ObjC++
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: [MEET] CocoaHeads Mac Developer Meetings
  • Next by Date: Re: Declaring a property named "private" and ObjC++
  • Previous by thread: [MEET] CocoaHeads Mac Developer Meetings
  • Next by thread: Re: Declaring a property named "private" and ObjC++
  • Index(es):
    • Date
    • Thread