X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type :content-transfer-encoding; q=dns; s=default; b=Mo3UDmUEg1V2FR/J YE6MLbK9z1B0ouDxSM6TuV9MXhPUq1T7PjlluIFMiKXYhX53rtvam+WJIB2m5XO/ d6UW2clQ7xa2K1MvLZ0kJqAUipheeelEHqgBMO1HkuDdvy8rahWwhdPZ18b1eCg1 03NH/DKuHSuFNOa6JBInIJMzXjE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type :content-transfer-encoding; s=default; bh=K4zfcizpcziUNdkWq7Z6ow deiG4=; b=ZfNvc1jMJPgLK+EDWIOk44SP4IyOdhBo1ZqqPBPOAWUEDJFfuuNRqm EXTkm9S4b2NV/0NgHLHan1tLjJm5QUYN4pTMw63Dvi9Zt0n62U43sCF8s7iBKN/1 q8D0yBsi1mxYMD1FKZHaN039KRMjkuDuwV7wkQb9jzpgt7A0JEK1Q= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f178.google.com MIME-Version: 1.0 X-Received: by 10.182.233.228 with SMTP id tz4mr388941obc.56.1393797315566; Sun, 02 Mar 2014 13:55:15 -0800 (PST) In-Reply-To: <5313A789.2080205@gmail.com> References: <5313A789 DOT 2080205 AT gmail DOT com> Date: Sun, 2 Mar 2014 22:55:15 +0100 Message-ID: Subject: Re: va_list and char* are ambiguous From: Irfan Adilovic To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id s22LtWjn024451 On Sun, Mar 2, 2014 at 10:50 PM, Václav Zeman wrote: > On 03/02/2014 10:45 PM, Irfan Adilovic wrote: >> On Sun, Mar 2, 2014 at 6:58 PM, Irfan Adilovic wrote: >>> irfan AT irfy:~$ cat x.cc >>> #include >>> #include >>> using namespace std; >>> void foo (...) { cout << "varargs\n"; } >>> void foo (va_list ap) { cout << "va_list\n"; } >>> int main () { >>> foo ((const char *)NULL); >>> foo ((char *)NULL); >>> } >>> irfan AT irfy:~$ make x >>> g++ x.cc -o x >>> irfan AT irfy:~$ ./x >>> varargs >>> va_list >>> $ uname -a >>> CYGWIN_NT-6.2 irfy 1.7.29(0.271/5/3) 2014-02-21 23:45 x86_64 Cygwin >>> >>> I would expect the varargs version of foo to be called both times -- >>> and it does on my linux machine -- but I get the above output under >>> Cygwin. It looks like va_list is defined in terms of char*. >>> >>> Can anyone confirm this behavior on their Cygwin installations? >>> >>> Is this behavior legal? (in terms of whatever standards apply) >>> >>> Is there a way to "fix" this? (i.e. typedef va_list as a pointer to a >>> struct defined just for the purpose of defining the va_list type) >>> >>> -- Irfan >> >> I forgot to mention that calling `foo ("");` will produce: >> >> x.cc:7:12: warning: deprecated conversion from string constant to >> 'char*' [-Wwrite-strings] >> foo (""); >> ^ >> >> at compile time and will end up calling va_list at runtime. > I suspect this is due to compatibility with MS compiler on 32 bit > windows, where va_list is also char*. > > Does it fail for AMD64 as well? I suspect it should not and it should > work. IIRC the AMD64 MS compiler uses different definition than the 32 > bit one. (I cannot check right now.) > > I do not think there is much that can be done about it. You will simply > have to rename one of the functions. > > -- > VZ I am on a 64-bit Windows 8 running 64-bit Cygwin, so no, it doesn't work. I'm not sure how stuff works behind the scenes when I compile my program under Cygwin, but I do not use anything from Windows explicitly -- in other words, I'm working with purely Linux code. Would recompiling gcc be an option? Or is va_list somehow hard-wired to the Windows version of it? -- Irfan -- 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