This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Segfault when call kernel32 function
- To: Jamie Guinan <guinan at bluebutton dot com>
- Subject: Re: Segfault when call kernel32 function
- From: Mumit Khan <khan at NanoTech dot Wisc dot EDU>
- Date: Thu, 6 Jan 2000 19:41:15 -0600 (CST)
- cc: Cygwin Mailing List <cygwin at sourceware dot cygnus dot com>
On Thu, 6 Jan 2000, Jamie Guinan wrote:
>
> I tried the same program with Mumit's gcc-2.95.2 distribution
> native on Win98. Same problem, "BuildCommDCB()" just keeps
> crashing. Both CRTDLL and MSVCRT versions.
>
> I think I can work around it with a combination of GetCommState()
> and SetCommState(), but I just find it weird that BuildCommDCB
> fails. Oh, well. :/
>
I believe the bug is in Windows itself. Even though the prototype
says that you can supply the first parameter as LPCSTR (ie.,
`const char *'), Windows kernel will try to play with the string
it in place (possibly reformatting it, or something of that sort).
Solution:
1. Use -fwritable-strings option when compiling. Bad.
2. Use a static or allocated buffer and pass that instead.
static char mode_str[] = "9600,...";
BuildCommDCB (mode_str, &dcb);
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com