DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 50JMLCsg1912543
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 50JMLCsg1912543
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=tePAPdmu
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 430D63858D39
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1737325271;
	bh=p6jMG7ODlhhtc+JuU4nc843Q3oJYax91QVSGEEhcaxo=;
	h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=tePAPdmufVbRinlzPxqkJt9Fe1RyyzAi7CRr78A5SWXTOVGEc1AbDeANLw8qZmXQe
	 TiE92AOhy47a31V/CvHXZCFcYrVhXPx+vcpIv1U/DHAH/eDXx1HXYszdVpnVReINeC
	 /Y13fvJrvPpAq0Q3Z7Q6AdVQn9sFew9F1PSJ8DWw=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B27E3858D21
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B27E3858D21
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737325207; cv=none;
 b=PPlcRpXZ/G1KjPO+Gx5/fd9E7WBTPHKAeW9lv2CXFM2BBcHsS8hH0yLoYnwCGJ/inJz1l+QnW7fDfIaO7WmOcJ3RvRD5qjGhXLiCjlGNV1zEwGqdX8f7QX5RLst+W5Zl8ypRCxFXJ1jh2xmzT9vaH1/HHosECQeu/seJHwn3jC8=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1737325207; c=relaxed/simple;
 bh=pntYBcpjhOFjk8mNowpQYxhfuLBBMhqHFZ21Qvr03lI=;
 h=DKIM-Signature:Date:From:Message-ID:To:Subject:MIME-Version;
 b=n4o/cbuLmfSrYVKP2whpBtmTENpwIcAmWlj5EvuJ16Mw+7s7213uQA300NK+JV2EeyEpQiKy7MUKF9XPQjMBuIrg3Lzhd488AoVHI1iG6L//7TI17eNs8Ky65HJLuL2tde0kQ1Jw1E8eN9Qi/fXhYbzivPQuijESYLavi4XM074=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B27E3858D21
X-Yandex-Fwd: 1
Date: Mon, 20 Jan 2025 01:18:15 +0300
X-Mailer: The Bat! (v9.3.4) Professional
Message-ID: <1853495935.20250120011815@yandex.ru>
To: Kaz Kylheku <kaz@kylheku.com>, cygwin@cygwin.com
Subject: Re: Bug? GetCommandLineW() missing arguments in 64 bit Cygwin.
In-Reply-To: <47aec32d20aa430fee8631836ca0530a@kylheku.com>
References: <47aec32d20aa430fee8631836ca0530a@kylheku.com>
MIME-Version: 1.0
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Andrey Repin via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Andrey Repin <anrdaemon@yandex.ru>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

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...


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
