• 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: warning: type `string' has a user-defined constructor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warning: type `string' has a user-defined constructor


  • Subject: Re: warning: type `string' has a user-defined constructor
  • From: "Shawn Erickson" <email@hidden>
  • Date: Wed, 12 Sep 2007 14:08:11 -0700

On 9/12/07, email@hidden <email@hidden> wrote:
> Hi
>
> I am using objective-c++ (or .mm files)
>
> In my header file I have defined a std::string variable.
>
> @interface MyStuff : NSObject
> {
>         std::string myString;
> }
>
> When compiling I get the warning: type `string' has a user-defined
> constructor.
>
> Then in my init method I get a BAD_ACCESS_EXE exception thrown when
> assigning a value to myString
>
> - (MyStuff *) init {
>         myString.assign("123");
> }
>
> I can kind of guess that myString constructor has not been called?

Review...

<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_10.html>

...and -fobjc-call-cxx-cdtors on the following page...

<http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html>

> What is the correct way of setting this up.

Personally I would switch to use a std::string* ivar and new/delete
the instance in the init / dealloc method.

-Shawn
_______________________________________________

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

References: 
 >warning: type `string' has a user-defined constructor (From: email@hidden)

  • Prev by Date: Re: NSBrowser background color
  • Next by Date: Custom pagination clipping
  • Previous by thread: warning: type `string' has a user-defined constructor
  • Next by thread: Re: warning: type `string' has a user-defined constructor
  • Index(es):
    • Date
    • Thread