Re: Very strange problem, static strings related
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