* lib/arpa_inet.in.h: Include c++defs.h.
(inet_ntop, inet_pton): Declare using the macros with C++ namespace
support.
* modules/arpa_inet (Depends-on): Add c++defs.
(Makefile.am): Substitute the contents of c++defs.h.
* modules/arpa_inet-tests (Depends-on): Add arpa_inet-c++-tests.
* modules/arpa_inet-c++-tests: New file.
* tests/test-arpa_inet-c++.cc: New file.
+2010-12-26 Bruno Haible <bruno@clisp.org>
+
+ arpa_inet: Use the common idioms with C++ support.
+ * lib/arpa_inet.in.h: Include c++defs.h.
+ (inet_ntop, inet_pton): Declare using the macros with C++ namespace
+ support.
+ * modules/arpa_inet (Depends-on): Add c++defs.
+ (Makefile.am): Substitute the contents of c++defs.h.
+ * modules/arpa_inet-tests (Depends-on): Add arpa_inet-c++-tests.
+ * modules/arpa_inet-c++-tests: New file.
+ * tests/test-arpa_inet-c++.cc: New file.
+
2010-12-25 Bruno Haible <bruno@clisp.org>
Fix more C++ link errors on Solaris 8.
#ifndef _GL_ARPA_INET_H
#define _GL_ARPA_INET_H
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
-#ifdef __cplusplus
-extern "C" {
-#endif
#if @GNULIB_INET_NTOP@
# if !@HAVE_DECL_INET_NTOP@
For more details, see the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
-extern const char *inet_ntop (int af, const void *restrict src,
- char *restrict dst, socklen_t cnt)
- _GL_ARG_NONNULL ((2, 3));
+_GL_FUNCDECL_SYS (inet_ntop, const char *,
+ (int af, const void *restrict src,
+ char *restrict dst, socklen_t cnt)
+ _GL_ARG_NONNULL ((2, 3)));
# endif
+_GL_CXXALIAS_SYS (inet_ntop, const char *,
+ (int af, const void *restrict src,
+ char *restrict dst, socklen_t cnt));
+_GL_CXXALIASWARN (inet_ntop);
#elif defined GNULIB_POSIXCHECK
# undef inet_ntop
# if HAVE_RAW_DECL_INET_NTOP
#if @GNULIB_INET_PTON@
# if !@HAVE_DECL_INET_PTON@
-extern int inet_pton (int af, const char *restrict src, void *restrict dst)
- _GL_ARG_NONNULL ((2, 3));
+_GL_FUNCDECL_SYS (inet_pton, int,
+ (int af, const char *restrict src, void *restrict dst)
+ _GL_ARG_NONNULL ((2, 3)));
# endif
+_GL_CXXALIAS_SYS (inet_pton, int,
+ (int af, const char *restrict src, void *restrict dst));
+_GL_CXXALIASWARN (inet_pton);
#elif defined GNULIB_POSIXCHECK
# undef inet_pton
# if HAVE_RAW_DECL_INET_PTON
# endif
#endif
-#ifdef __cplusplus
-}
-#endif
#endif /* _GL_ARPA_INET_H */
#endif /* _GL_ARPA_INET_H */
Depends-on:
arg-nonnull
+c++defs
include_next
sys_socket
warn-on-use
# We need the following in order to create <arpa/inet.h> when the system
# doesn't have one.
-arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+arpa/inet.h: arpa_inet.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) arpa
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
-e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
-e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/arpa_inet.in.h; \
--- /dev/null
+Files:
+tests/test-arpa_inet-c++.cc
+tests/signature.h
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += test-arpa_inet-c++
+check_PROGRAMS += test-arpa_inet-c++
+test_arpa_inet_c___SOURCES = test-arpa_inet-c++.cc
+test_arpa_inet_c___LDADD = $(LDADD) $(INET_NTOP_LIB) $(INET_PTON_LIB) $(LIBSOCKET)
+endif
tests/test-arpa_inet.c
Depends-on:
+arpa_inet-c++-tests
configure.ac:
--- /dev/null
+/* Test of <arpa/inet.h> substitute in C++ mode.
+ Copyright (C) 2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
+
+#define GNULIB_NAMESPACE gnulib
+#include <config.h>
+
+#include <arpa/inet.h>
+
+#include "signature.h"
+
+
+#if GNULIB_TEST_INET_NTOP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::inet_ntop, const char *,
+ (int, const void *, char *, socklen_t));
+#endif
+
+#if GNULIB_TEST_INET_PTON
+SIGNATURE_CHECK (GNULIB_NAMESPACE::inet_pton, int,
+ (int, const char *, void *));
+#endif
+
+
+int
+main ()
+{
+}