[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
msvc port: ensure size_t
From: |
Bruno Haible |
Subject: |
msvc port: ensure size_t |
Date: |
Sun, 11 Sep 2011 18:25:30 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
On MSVC 9, size_t is defined by <stddef.h> but not by <sys/types.h>. This leads
to compilation errors in strings.h and sys/uio.h, because the gnulib
replacements of these files assume that <sys/types.h> defines size_t.
We cannot put the replacement in <config.h>, like for pid_t, because then it
would collide with the size_t definition in <stddef.h>.
So the fix is to create a new module 'sys_types'.
2011-09-11 Bruno Haible <address@hidden>
New module 'sys_types'.
* lib/sys_types.in.h: New file.
* m4/sys_types_h.m4: New file.
* modules/sys_types: New file.
* doc/posix-headers/sys_types.texi: Mention the new module and the
size_t problem on MSVC 9.
============================= lib/sys_types.in.h =============================
/* Provide a more complete sys/time.h.
Copyright (C) 2011 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
#ifndef address@hidden@_SYS_TYPES_H
/* The include_next requires a split double-inclusion guard. */
address@hidden@ @NEXT_SYS_TYPES_H@
#ifndef address@hidden@_SYS_TYPES_H
#define address@hidden@_SYS_TYPES_H
/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
/* But avoid namespace pollution on glibc systems. */
#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
&& ! defined __GLIBC__
# include <stddef.h>
#endif
#endif /* address@hidden@_SYS_TYPES_H */
#endif /* address@hidden@_SYS_TYPES_H */
============================== m4/sys_types_h.m4 ==============================
# sys_types_h.m4 serial 1
dnl Copyright (C) 2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_SYS_TYPES_H],
[
AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
gl_NEXT_HEADERS([sys/types.h])
dnl Ensure the type pid_t gets defined.
AC_REQUIRE([AC_TYPE_PID_T])
])
AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
[
])
============================== modules/sys_types ==============================
Description:
A <sys/types.h> that conforms better to POSIX.
Files:
lib/sys_types.in.h
m4/sys_types_h.m4
Depends-on:
include_next
configure.ac:
gl_SYS_TYPES_H
AC_PROG_MKDIR_P
Makefile.am:
BUILT_SOURCES += sys/types.h
# We need the following in order to create <sys/types.h> when the system
# doesn't have one that works with the given compiler.
sys/types.h: sys_types.in.h $(top_builddir)/config.status
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f address@hidden $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
< $(srcdir)/sys_types.in.h; \
} > address@hidden && \
mv address@hidden $@
MOSTLYCLEANFILES += sys/types.h sys/types.h-t
Include:
<sys/types.h>
License:
LGPLv2+
Maintainer:
all
===============================================================================
--- doc/posix-headers/sys_types.texi.orig Sun Sep 11 18:11:20 2011
+++ doc/posix-headers/sys_types.texi Sun Sep 11 17:36:41 2011
@@ -3,16 +3,18 @@
POSIX specification:@*
@url{http://www.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html}
-Gnulib module: ---
+Gnulib module: sys_types
Portability problems fixed by Gnulib:
@itemize
address@hidden
+The type @code{pid_t} is not defined on some platforms:
+MSVC 9.
address@hidden
+The type @code{size_t} is not defined in this file on some platforms:
+MSVC 9.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
address@hidden
-The type @code{pid_t} is not defined on some platforms:
-MSVC 9.
-You can use the macro @code{AC_TYPE_PID_T} to fix this.
@end itemize
2011-09-11 Bruno Haible <address@hidden>
Support for MSVC compiler: Ensure size_t gets defined.
* modules/strings (Depends-on): Add 'sys_types'.
* modules/sys_uio (Depends-on): Likewise.
* lib/sys_uio.in.h: Update comment.
--- lib/sys_uio.in.h.orig Sun Sep 11 18:21:03 2011
+++ lib/sys_uio.in.h Sun Sep 11 17:57:52 2011
@@ -37,7 +37,7 @@
#if address@hidden@
/* A platform that lacks <sys/uio.h>. */
-/* Get 'ssize_t'. */
+/* Get 'size_t' and 'ssize_t'. */
# include <sys/types.h>
# ifdef __cplusplus
--- modules/strings.orig Sun Sep 11 18:21:03 2011
+++ modules/strings Sun Sep 11 17:57:27 2011
@@ -10,6 +10,7 @@
snippet/arg-nonnull
snippet/c++defs
snippet/warn-on-use
+sys_types
configure.ac:
gl_HEADER_STRINGS_H
--- modules/sys_uio.orig Sun Sep 11 18:21:03 2011
+++ modules/sys_uio Sun Sep 11 17:57:27 2011
@@ -7,6 +7,7 @@
Depends-on:
include_next
+sys_types
configure.ac:
gl_HEADER_SYS_UIO
--
In memoriam Georgi Markov <http://en.wikipedia.org/wiki/Georgi_Markov>
- msvc port: ensure size_t,
Bruno Haible <=