wxWidgets and string & iostream
Teo Fonrouge
teo at windtelsoft.com
Wed Sep 6 07:39:16 PDT 2006
On Tue, 2006-09-05 at 13:32 +0200, Fibre Optic wrote:
> Teo Fonrouge wrote:
> >
> > Yes, I used to have lots of cout's to make tracelogs. Now I use the
> > wxWidgets wxLog* classes, are more powerfull & portable to do program
> > tracelogs.
> >
> > Have you tried to use a debug utility to do a trace ?.
> > Is your cout iostream a valid one ? ( maybe a full or invalid device is
> > causing the seg fault).
> >
> > By the way :), what platform & libs versions are you using ?, could be
> > useful to know your current environment settings.
> >
> >> Regards,
> >> Fibre Optic
> >
> > best regards
> > Teo Fonrouge
>
> platform: win32 + mingw port of GCC
> wxWidgets lib: i have compiled/linked the library from sources of CVS
> repository
>
> the code is as follows:
>
> #include <wx/wx.h>
> #include <wx/regex.h>
> #include <stdio.h>
> #include <iostream>
> #include <string>
>
> int main(int argc, int arg[])
> {
> char regex[255];
> wxString cookieField =
> wxT("Njky=gg6435345b at APC216@172.16.1.15 at D34fD$F$F$F");
>
> std::cout << "cookieField: " << cookieField.mb_str() << std::endl;
>
> wxString userID;
> char *p;
>
> printf("Enter cookie RegEx and press enter: ");
> fgets(regex, sizeof(regex), stdin);
>
> //now remove \n
> if ((p = strchr(regex, '\n')) != NULL);
> *p = '\0';
>
> wxRegEx cookieRegEx(wxT(regex));
Just a little observation, the above sentence wont't compile in a
wxWidgets UNICODE version libs because the wrong use of the wxT(...)
macro.
>
> if (cookieRegEx.Matches(cookieField)) {
> userID = cookieRegEx.GetMatch(cookieField, 1);
> printf("User ID: %s\n", userID.c_str());
> }
> }
>
> and here is stack trace:
>
> wxRegEx-Test.exe caused an Access Violation at location 7c918fea in
> module ntdll.dll Writing to location 00000010.
>
> Registers:
> eax=00000000 ebx=00000000 ecx=00000000 edx=73dae7b0 esi=73dae7b0
> edi=00000000
> eip=7c918fea esp=0023fc1c ebp=0023fc90 iopl=0 nv up ei pl nz na
> pe nc
> cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000
> efl=00000202
>
> Call stack:
> 7C918FEA ntdll.dll:7C918FEA RtlpWaitForCriticalSection
> 7C90104B ntdll.dll:7C90104B RtlEnterCriticalSection
> 77C40E8B msvcrt.dll:77C40E8B fputc
> 005BB47F wxRegEx-Test.exe:005BB47F _GLOBAL__D_main wxRegEx-Test.cpp:32
> ...
> }
>
> ...
>
> 005D4F8C wxRegEx-Test.exe:005D4F8C _GLOBAL__D_main wxRegEx-Test.cpp:32
> ...
> }
>
> ...
>
> 005E60F2 wxRegEx-Test.exe:005E60F2 _GLOBAL__D_main wxRegEx-Test.cpp:32
> ...
> }
>
> ...
>
> 004013BA wxRegEx-Test.exe:004013BA main wxRegEx-Test.cpp:17
> ...
> char *p;
>
> > printf("Enter cookie RegEx and press enter: ");
> fgets(regex, sizeof(regex), stdin);
>
> ...
>
> 00401237 wxRegEx-Test.exe:00401237
> 00401288 wxRegEx-Test.exe:00401288
> 7C816FD7 kernel32.dll:7C816FD7 RegisterWaitForInputIdle
>
>
> If I have overlooked something let me know.
Unfortunately I had not experience with mingw :(, however your sample
compiles and runs ok in my Linux FC5 environment.
Maybe someone used to mingw can give some light on this problem.
>
> Regards,
> Fibre Optic
>
best regards
Teo Fonrouge
More information about the wx-users
mailing list