• 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: New in Xcode 4 : Local var in C function has "protected destructor" ?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New in Xcode 4 : Local var in C function has "protected destructor" ?!?


  • Subject: Re: New in Xcode 4 : Local var in C function has "protected destructor" ?!?
  • From: Michael Babin <email@hidden>
  • Date: Sun, 05 Aug 2012 09:27:32 -0500

On Aug 5, 2012, at 1:28 AM, Jerry Krinock <email@hidden> wrote:

> A project includes a dynamic library which is called by JavaScript in my Firefox extension, via Mozilla's "CTypes" bridge.  One of its functions needs to talk C++ (and Obj-C), so I put it in a .mm "shim" file.  Also, CTypes requires that functions be declared externally as pure "C", not C++, so I wrap it in an 'extern "C"' block.  This also avoids name mangling. [1]
>
> All worked fine in Xcode 3.   But when I try to build the project in Xcode 4, an error occurs in this file at the *declaration* of a local variable, because it "has a protected destructor".  This makes no sense to me at all.  It's not even in a C++ class.  What in the world might be going on?
>
> Thanks,
>
> Jerry Krinock
>
> ******* SSYFirefoxCToCppShim.h *******
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>    void ProcessClientRequest(
>                          char headerByte,
>                          NSData* data,
>                          char* responseHeaderByte_p,
>                          NSData** payload_p
>                          ) ;
> #ifdef __cplusplus
> }
> #endif
>
>
> ******* SSYFirefoxCToCppShim.mm *******
>
> extern "C" {
>    void ProcessClientRequest(
>                              char headerByte,
>                              NSData* data,
>                              char* responseHeaderByte_p,
>                              NSData** payload_p
>                              ) {
>        ...
>        nsACString nsacString ;
>        //  !!!!!!!!!!!!!!! ERROR ON PRECEDING LINE: !!!!!!!!!!!!!!!
>        // "Variable of type 'nsACString' has protected destructor."
>
>        if (ourJavascriptComponent != NULL) {
>            switch (headerByte) {
>                case constInterappHeaderByteForGrabRequest:
>                    // Note that nsacString is an *output* parameter from SsyJsGrabPage
>                    jsonText = [[NSString alloc] initWithBytes:nsacString.BeginReading()
>                                                        length:nsacString.Length()
>                                                      encoding:NSUTF8StringEncoding] ;
>                    ...
>                    break ;
>                case …
>                case …
>                case …
>                default:
>                    ;
>            }
>        }
>        ...
>    }
> }

It's complaining about your creation of an instance of nsACString. According to the docs at:

https://developer.mozilla.org/en-US/docs/nsACString

"The nsACString class is never instantiated directly. It should be instantiated using a subclass, such as nsEmbedCString."

If you look at the class declaration for nsACString, it no doubt show that the destructor is a protected method, perhaps something like:

> protected:
>    // Prevent people from allocating a nsAString directly.
>    ~nsACString() {}

I'm not familiar enough with the string class hierarchy of nsStringAPI to recommend which subclass(es) you might want to use instead.


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

This email sent to email@hidden


  • Follow-Ups:
    • Re: New in Xcode 4 : Local var in C function has "protected destructor" ?!? [solved]
      • From: Jerry Krinock <email@hidden>
References: 
 >New in Xcode 4 : Local var in C function has "protected destructor" ?!? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: No teams showing in organizer
  • Next by Date: Where is CGAffineTransformRotate?
  • Previous by thread: New in Xcode 4 : Local var in C function has "protected destructor" ?!?
  • Next by thread: Re: New in Xcode 4 : Local var in C function has "protected destructor" ?!? [solved]
  • Index(es):
    • Date
    • Thread