openMSX / wxcatapult

23 stars 4 forks source link

[Bug] wxCatapult: when built on mingw or msvc win32, "catapult.exe --version" emits nothing. [sf#485] #18

Open openMSX-import opened 9 years ago

openMSX-import commented 9 years ago

Reported by joxy on 2013-07-30 05:54 UTC Must emit a textual version info.

openMSX-import commented 9 years ago

Updated by joxy on 2013-08-01 05:10 UTC

openMSX-import commented 9 years ago

Commented by joxy on 2013-08-04 09:24 UTC (18:20:46) egp: f*ck (18:20:59) egp: I call HANDLE hStdOut = ::GetStdHandle(STD_OUTPUTHANDLE); in mingw (18:21:04) egp: it returns OK (18:21:32) egp: and returns an OK handle (18:21:33) egp: but ::WriteFile gives "Bad descriptor" for the above handle (18:21:47) egp: that's why --version doesn't work in Windows (18:22:08) egp: Any thoughts on this "Bad descriptor"?

Any Windows gurus here?

I don't kinda want to invest too much time in Windows internals, so I give up on this bug

openMSX-import commented 9 years ago

Updated by joxy on 2013-08-04 09:28 UTC

openMSX-import commented 9 years ago

Commented by manuelbi on 2013-08-04 16:36 UTC Why do you need all that HANDLE stuff?? Isn't it a matter to simply print a string?

I made some version stuff a bit simpler today, maybe it helps, let me know.

openMSX-import commented 9 years ago

Commented by joxy on 2013-08-04 19:38 UTC Manuel, I tried std::wcout — this doesn't help. I didn't try std::cout.

openMSX-import commented 9 years ago

Commented by manuelbi on 2013-08-04 20:00 UTC Does it work with the current code?

If not, did you try to find out where it is going wrong? E.g., perhaps the VERSION info is simply not generated correctly. Did you look at the generated Version.ii? Is the version in the About box correct with MinGW?

openMSX-import commented 9 years ago

Commented by joxy on 2013-08-04 20:23 UTC Wrong place is where something like ::WriteFile gets called and reports "Bad descriptor" for STD_OUT.

openMSX-import commented 9 years ago

Commented by manuelbi on 2013-08-04 20:29 UTC I found that line: line 1182 in openMSXController.cpp.

But that code is writing the XML to openMSX. It has nothing to do with printing the version of wxCatapult...

Is that part of the code also giving problems?

openMSX-import commented 9 years ago

Updated by joxy on 2013-08-05 08:37 UTC

openMSX-import commented 9 years ago

Commented by joxy on 2013-08-05 08:59 UTC Manuel:

std:cout doesn not fix this bug. I just tested --version.

Yes. Version.ii is fine.

With mingw32, the About box and its versions labels are fine.

openMSX-import commented 9 years ago

Commented by joxy on 2013-08-05 09:18 UTC GetLastError returns 0 (success)...

openMSX-import commented 9 years ago

Commented by m9710797 on 2013-08-05 10:11 UTC Printing something on stdout in c++ should be as simple as:

include

... std::cout << "Hello, world!" << std::endl;

Unfortunately unicode stuff complicates things a bit. I won't go into all the details. But the short story is that to be portable you can only (easily) print ascii text. but for our --version stuff that's all we need.

To print utf-8 strings (that only contains ascii chars) you don't need to do any conversion. To print wxStrings (that only contains ascii chars) you first have to convert them via the ToAscii() method. So:

std::string myUTF8String = ...; wxString myWxString = ...;

std::cout << "This is a std::string " << myUTF8String << std::endl; std::cout << "This is a wxString " << myWxString.ToAscii() << std::endl;

Wouter

On Sun, Aug 4, 2013 at 10:23 PM, joxy joxy@users.sf.net wrote:

Wrong place is where something like ::WriteFile gets called and reports "Bad descriptor" for STD_OUT.


[bugs:#485] wxCatapult: when built on mingw or msvc win32, "catapult.exe --version" emits nothing.

Status: open Labels: wxCatapult Created: Tue Jul 30, 2013 05:54 AM UTC by joxy Last Updated: Sun Aug 04, 2013 08:00 PM UTC Owner: nobody

Must emit a textual version info.


Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/openmsx/bugs/485/

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

openMSX-import commented 9 years ago

Commented by manuelbi on 2013-08-05 21:06 UTC You can really assume that std::cout works on Windows, There's no need to dive into the platform specific code that lies under that. There must be some other thing going on.

openMSX-import commented 9 years ago

Commented by joxy on 2013-08-11 20:55 UTC Tested. GetLastError / FormatMessage return smth like "No error" after std::cout << call. Though this call emits nothing to the stdout.

I guess maybe wxWidgets initialize the CRT strangely...