2010-03-07 Bruno Haible <bruno@clisp.org>
+ fcntl-h: Avoid #define replacements in C++ mode.
+ * lib/fcntl.in.h: Include c++defs.h.
+ (fcntl, open, openat): In C++, define a namespaced alias symbol.
+ * modules/fcntl-h (Depends-on): Add c++defs.
+ (Makefile.am): Update fcntl.h rule.
+
dirent: Avoid #define replacements in C++ mode.
* lib/dirent.in.h: Include c++defs.h.
(closedir, fdopendir, opendir, scandir, alphasort): In C++, define a
#endif
+/* 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. */
/* Declare overridden functions. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#if @GNULIB_FCNTL@
# if @REPLACE_FCNTL@
-# undef fcntl
-# define fcntl rpl_fcntl
-# endif
-# if !@HAVE_FCNTL@ || @REPLACE_FCNTL@
-extern int fcntl (int fd, int action, ...);
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fcntl
+# define fcntl rpl_fcntl
+# endif
+_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
+_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
+# else
+# if !@HAVE_FCNTL@
+_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
+# endif
+_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
# endif
+_GL_CXXALIASWARN (fcntl);
#elif defined GNULIB_POSIXCHECK
# undef fcntl
# if HAVE_RAW_DECL_FCNTL
#if @GNULIB_OPEN@
# if @REPLACE_OPEN@
-# undef open
-# define open rpl_open
-extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1));
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef open
+# define open rpl_open
+# endif
+_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
+# else
+_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
# endif
+_GL_CXXALIASWARN (open);
#elif defined GNULIB_POSIXCHECK
# undef open
/* Assume open is always declared. */
#if @GNULIB_OPENAT@
# if @REPLACE_OPENAT@
-# undef openat
-# define openat rpl_openat
-# endif
-# if !@HAVE_OPENAT@ || @REPLACE_OPENAT@
-extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
- _GL_ARG_NONNULL ((2));
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef openat
+# define openat rpl_openat
+# endif
+_GL_FUNCDECL_RPL (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...));
+# else
+# if !@HAVE_OPENAT@
+_GL_FUNCDECL_SYS (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...)
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (openat, int,
+ (int fd, char const *file, int flags, /* mode_t mode */ ...));
# endif
+_GL_CXXALIASWARN (openat);
#elif defined GNULIB_POSIXCHECK
# undef openat
# if HAVE_RAW_DECL_OPENAT
# endif
#endif
-#ifdef __cplusplus
-}
-#endif
/* Fix up the FD_* macros, only known to be missing on mingw. */
Depends-on:
arg-nonnull
+c++defs
extensions
include_next
unistd
# We need the following in order to create <fcntl.h> when the system
# doesn't have one that works with the given compiler.
-fcntl.h: fcntl.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+fcntl.h: fcntl.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
-e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
-e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|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)/fcntl.in.h; \