This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] Fix C++ compilation of wait(NULL)
- From: Christian Franke <Christian dot Franke at t-online dot de>
- To: cygwin-patches at cygwin dot com
- Date: Wed, 08 Feb 2012 19:39:48 +0100
- Subject: [PATCH] Fix C++ compilation of wait(NULL)
This fixes the regression I introduced in sys/wait.h.
Sorry, and thanks for the bug report.
Christian
2012-02-08 Christian Franke <franke@computer.org>
* include/sys/wait.h: Remove C++ inline functions for `union wait'.
For C++ use `void *' as __wait_status_ptr_t instead.
This is less type safe but fixes compile error on `wait(NULL)'.
Remove extra `;'.
diff --git a/winsup/cygwin/include/sys/wait.h b/winsup/cygwin/include/sys/wait.h
index 71ede93..78f5d06 100644
--- a/winsup/cygwin/include/sys/wait.h
+++ b/winsup/cygwin/include/sys/wait.h
@@ -19,11 +19,16 @@ details. */
extern "C" {
#endif
-#ifdef __cplusplus
+#ifdef __INSIDE_CYGWIN__
typedef int *__wait_status_ptr_t;
-#else /* !__cplusplus */
+#elif defined(__cplusplus)
+
+/* Attribute __transparent_union__ is only supported for C. */
+typedef void *__wait_status_ptr_t;
+
+#else /* !__INSIDE_CYGWIN__ && !__cplusplus */
/* Allow `int' and `union wait' for the status. */
typedef union
@@ -32,7 +37,7 @@ typedef union
union wait *__union_wait_ptr;
} __wait_status_ptr_t __attribute__ ((__transparent_union__));
-#endif /* __cplusplus */
+#endif /* __INSIDE_CYGWIN__ */
pid_t wait (__wait_status_ptr_t __status);
pid_t waitpid (pid_t __pid, __wait_status_ptr_t __status, int __options);
@@ -77,17 +82,7 @@ inline int __wait_status_to_int (int __status)
{ return __status; }
inline int __wait_status_to_int (const union wait & __status)
{ return __status.w_status; }
-
-/* C++ wait() variants for `union wait'. */
-inline pid_t wait (union wait *__status)
- { return wait ((int *) __status); }
-inline pid_t waitpid (pid_t __pid, union wait *__status, int __options)
- { return waitpid(__pid, (int *) __status, __options); }
-inline pid_t wait3 (union wait *__status, int __options, struct rusage *__rusage)
- { return wait3 ((int *) __status, __options, __rusage); }
-inline pid_t wait4 (pid_t __pid, union wait *__status, int __options, struct rusage *__rusage)
- { return wait4 (__pid, (int *) __status, __options, __rusage); }
-};
+}
#else /* !__cplusplus */