Problem with: Re: [PATCH] Allow usage of union wait for wait() functions and macros

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Thu Dec 8 16:26:00 GMT 2011


On Thu, Dec 08, 2011 at 07:42:48AM +0100, Christian Franke wrote:
>Christopher Faylor wrote:
>> On Thu, Dec 08, 2011 at 12:17:11AM +0100, Christian Franke wrote:
>>> Christopher Faylor wrote:
>>>> ...
>>>> /usr/local/src/trunk/objdir.withada/./prev-gcc/g++
>>>> -B/usr/local/src/trunk/objdir.withada/./prev-gcc/
>>>> ...
>>>> -I/usr/local/src/trunk/gcc/gcc/../libdecnumber/bid -I../libdecnumber
>>>>     /usr/local/src/trunk/gcc/gcc/ada/adaint.c -o ada/adaint.o
>>>> In file included from /usr/local/src/trunk/gcc/gcc/system.h:346:0,
>>>>                    from /usr/local/src/trunk/gcc/gcc/ada/adaint.c:107:
>>>> /usr/include/sys/wait.h: In function 'int __wait_status_to_int(const wait&)':
>>>> /usr/include/sys/wait.h:77:61: error: declaration of C function 'int
>>>> __wait_status_to_int(const wait&)' conflicts with
>>>> /usr/include/sys/wait.h:75:12: error: previous declaration 'int
>>>> __wait_status_to_int(int)' here
>>> This suggests that sys/wait.h is included within an extern "C" { ... }
>>> block.
>>> If this is the case then an extern "C++" {...} block around the C++
>>> inline functions of sys/wait.h should fix this.
>>> See:
>>> http://cygwin.com/ml/cygwin-patches/2011-q4/msg00005.html
>> Yes, I'm responding to this very thread.
>>
>> But, I don't see how extern "c++" fixes anything.  #ifdef __cplusplus maybe...
>
>No, #ifdef __cplusplus won't help. Example:
>
>foo.h:
>extern "C" {
>#include <sys/wait.h>
>}
>
>
>sys/wait.h:
>...
>#ifdef __cplusplus
>...
>inline int __wait_status_to_int(int __status) { .... }
>// This fails because both are interpreted as C-functions:
>inline int __wait_status_to_int(const union wait &__status) { .... }
>...
>#endif
>
>
>Fix:
>#ifdef __cplusplus
>+extern "C++" {
>...
>inline int __wait_status_to_int(int __status) { .... }
>inline int __wait_status_to_int(const union wait &__status) { .... }
>...
>+}
>#endif

I've added that to sys/wait.h.  Thanks.

cgf



More information about the Cygwin-patches mailing list