home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.os2.programmer
- Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!informatik.tu-muenchen.de!rommel
- From: rommel@Informatik.TU-Muenchen.DE (Kai-Uwe Rommel)
- Subject: Re: EMX library bug.
- References: <ReiBoB5w164w@dvss.UUCP> <1992Jul22.185306.10692@ampex.com>
- Sender: news@Informatik.TU-Muenchen.DE (USENET Newssystem)
- Organization: Technische Universitaet Muenchen, Germany
- Date: Thu, 23 Jul 1992 07:33:07 GMT
- Message-ID: <1992Jul23.073307.10996@Informatik.TU-Muenchen.DE>
- Lines: 32
-
- In article <1992Jul22.185306.10692@ampex.com> cjensen@ampex.com (Colin Jensen) writes:
- >In article <ReiBoB5w164w@dvss.UUCP> dvss!jtroy@udel.edu (Jay Troy) writes:
- >>I think I've discovered an EMX library bug. The standard library function
- >>strtok causes an access violation in every combination that I've tried. The
- >>following simple C program illustrates this problem:
- >
- >> char *ch = "3.4 4.1";
- >> strcpy(temp, strtok(ch," "));
- >
- >I don't know anything about EMX, but your code is certainly problematic.
- >A C compiler is free to store strings constants like "3.4 4.1" in
- >read-only memory [hence their name]. Since strtok will try to write
- >into that memory, an access violation should be expected.
- >
- >To be portable, you need to copy that string either into an automatic variable
- >or copy it into some malloc'ed memory.
- >
- >Under UNIX, you can pass gcc the option -fwritable-strings to tell gcc you
- >really want to be able to write into string constants. Perhaps this would
- >solve your problem with EMX.
- >--
- >Colin Jensen (cjensen@ampex.com)
-
- Yes, -fwritable-strings solves this problem. Try it.
-
- Kai Uwe Rommel
-
- /* Kai Uwe Rommel --- rommel@informatik.tu-muenchen.de */
-
- DOS ... is still a real mode only non-reentrant interrupt
- handler, and always will be. -Russell Williams
-
-