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@irfy:~$ cat x.cc >>> #include <cstdarg> >>> #include <iostream> >>> 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@irfy:~$ make x >>> g++ x.cc -o x >>> irfan@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