This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: BUG: winmain GetCommandLine only returning program name and path with no arguments
- From: Brian Inglis <Brian dot Inglis at SystematicSw dot ab dot ca>
- To: cygwin at cygwin dot com
- Date: Sat, 13 May 2017 10:45:53 -0600
- Subject: Re: BUG: winmain GetCommandLine only returning program name and path with no arguments
- Authentication-results: sourceware.org; auth=none
- References: <CAF_6hF4+jNWuqA-7jSn2=Jqb2X--MDmY0qhbNwtLxBcHwkrxbA@mail.gmail.com>
- Reply-to: Brian dot Inglis at SystematicSw dot ab dot ca
On 2017-05-13 08:30, Mike Barry wrote:
> Below is a sample program that demonstrates that the GetCommandLine
> function is not returning the command line arguments. I attached
> cygcheck.out.
>
> #include <windows.h>
> #include <stdio.h>
>
> int WINAPI
> WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {
> char* text = GetCommandLine();
> printf("getcmdline: %s\n", text);
> return 0;
> }
>
> gcc test_wmain.c -o test
>
> $ ./test hello world
> getcmdline: "C:\cygwin64\home\mbarry\game-repos\greenbeam\src\test.exe"
Cygwin program startup may have already taken care of the command line.
If you're using Cygwin, lose the MS cruft, and define a standard non-MS:
int
main( int argc, char **argv) {
...
}
and process the args with getopt as usual.
You could try Mingw or VS, but even there I believe you can use standard
main().
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple