Bug? GetCommandLineW() missing arguments in 64 bit Cygwin.

Andrey Repin anrdaemon@yandex.ru
Sun Jan 19 22:18:15 GMT 2025


Greetings, Kaz Kylheku!

> Hi All, 

> In a (admittedly not current) version of 64 bit Cygwin, I'm observing a funny
> behavior:

> The GetCommandLineW function returns a command line which consists of the
> executable name only; the arguments are missing.

Why you are using native calls inside Cygwin executable?

> This issue goes away when the program is run under GDB; the arguments
> prepared by GDB do then appear in the command line.

> The issue is not seen under 32 bits.

> The repro program uses WinMain; I've not compared whether using
> main makes a difference:

You really should.

> #include <windows.h>
> #include <stdio.h>
> #include <wchar.h>

> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
>                    LPSTR lpCmdLine, int nShowCmd)
> {
>   int argc, i;
>   LPWSTR cmdline = GetCommandLineW();
>   wprintf(L"cmdline = %ls\n", cmdline);
>   return 0;
> }

Aside from the fact you shouldn't do that (calling native API's in Cygwin app
without a very good reason), what is your CYGWIN env setting?


-- 
With best regards,
Andrey Repin
Monday, January 20, 2025 01:16:12

Sorry for my terrible english...



More information about the Cygwin mailing list