• 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: Very strange problem, static strings related
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very strange problem, static strings related


  • Subject: Re: Very strange problem, static strings related
  • From: Wim Lewis <email@hidden>
  • Date: Mon, 01 Oct 2012 12:46:15 -0700


On 27 Sep 2012, at 8:05 PM, Igor Delovski wrote:
As I got this message from the list, it became "someone else's problem" and as I read it, the string "912" became obviously Sptember of this year and then I found the problem in a second. A function like this:

void Something (..., char *aDate, ...)
{
   if (!aDate[0])
      strcpy (aDate, GetMeMonthYear());
   ...
}

And it was called like this: Something (..., "", ...);

Sorry to bother you all with nothing.


For what it's worth, the default compiler settings for new projects make C string literals unwritable. Old code sometimes depends on being able to write to them, and presumably your project is being built with the -fwritable-strings flag for compatibility. If you don't need to be able to modify string constants, you should probably disable -fwritable-strings — it will save you from hassles like this and will make your program (slightly) more memory-efficient.

(If you *do* need to be able to modify string constants, I strongly recommend turning off -fwritable-strings anyway and fixing your code to use "char foo[...]", malloc, or some other way of creating a writable buffer.)


 _______________________________________________
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: Very strange problem, static strings related
      • From: Igor Delovski <email@hidden>
  • Prev by Date: Re: Xcode4.5's version of pngcrush making images larger!
  • Next by Date: Re: Very strange problem, static strings related
  • Previous by thread: Re: Typing a : puts [] around stuff
  • Next by thread: Re: Very strange problem, static strings related
  • Index(es):
    • Date
    • Thread