This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
BUG in function parameter passing ??????
- To: Mark dot Koennecke at psi dot ch
- Subject: BUG in function parameter passing ??????
- From: Charles G Waldman <cgw at pgt dot com>
- Date: Thu, 27 Aug 1998 21:32:13 -0400 (EDT)
- Cc: GNU-WIN32 at cygnus dot com
- References: <98082711213612@psicla.psi.ch>
Mark.Koennecke@psi.ch writes:
>
> int main(int argc, char *argv[])
> {
> char pBuffer[132];
>
> /* why does this work? */
> strcpy(pBuffer,"Hello You");
> strtolower(pBuffer);
>
> /* but this gives a segmentation violation under Cygwin*/
> strtolower("Hello You");
>
Because the string "Hello You" is a constant, and is allocated in the
read-only segment of the executable. The buffer pBuffer is allocated
read/write. This is done so that storage for literal strings can be
shared between object files.
There's a compiler option to turn off this behavior. Try adding
-fwritable-strings to your compilation flags.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".