Eric Blake wrote:

> +/* All known platforms that lack <sys/uio.h> also lack any declaration
> +   of struct iovec in any other header.  */
> +struct iovec {
> +  void *iov_base;
> +  size_t iov_len;
> +};

When we define a 'struct' type in a gnulib header, we need to take care of
two things:
  - In the situation where the user has two gnulib-tool invocations within
    the same project, avoid a collision between the two gnulib-generated
    <sys/uio.h> files.
  - In C++, define the type as a C type, not as a C++ class.


2011-04-30  Bruno Haible  <br...@clisp.org>

        sys_uio: Protect definition of 'struct iovec'.
        * lib/sys_uio.in.h (struct iovec): Avoid redefinition. In C++, define
        it as a C struct.

--- lib/sys_uio.in.h.orig       Sat Apr 30 13:17:55 2011
+++ lib/sys_uio.in.h    Sat Apr 30 13:16:39 2011
@@ -37,12 +37,24 @@
 /* Get 'ssize_t'.  */
 # include <sys/types.h>
 
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if !GNULIB_defined_struct_iovec
 /* All known platforms that lack <sys/uio.h> also lack any declaration
    of struct iovec in any other header.  */
 struct iovec {
   void *iov_base;
   size_t iov_len;
 };
+#  define GNULIB_defined_struct_iovec 1
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
 #endif
 
 #endif /* _GL_SYS_UIO_H */

-- 
In memoriam Casey Jones <http://en.wikipedia.org/wiki/Casey_Jones>

Reply via email to