bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] Allow mbswidth() in C++ programs


From: Bruno Haible
Subject: Re: [Bug-gnulib] Allow mbswidth() in C++ programs
Date: Fri, 16 Jul 2004 18:16:23 +0200
User-agent: KMail/1.5

Albert Chin wrote:
> Allow use of functions in lib/mbswidth.h in C++ programs (lftp uses
> it).

Thanks, I'm adding an extern "C" around the .h file.

> BTW, shouldn't every replacement function in lib have the extern "C"
> wrapper?

We do it on an as-needed basis. GNU gettext needs C++ support for
alloca_.h allocsa.h backupfile.h closeout.h copy-file.h error.h
fatal-signal.h findprog.h fnmatch_.h full-write.h getopt.h localcharset.h
obstack.h pathname.h pipe.h progname.h setenv.h stdbool_.h stpcpy.h
stpncpy.h strcase.h strstr.h vasprintf.h wait-process.h xalloc.h xsetenv.h,
so I'm committing this patch.


2004-07-16  Bruno Haible  <address@hidden>

        * backupfile.h: Add extern "C" for C++.
        * closeout.h: Likewise.
        * copy-file.h: Likewise.
        * findprog.h: Likewise.
        * full-write.h: Likewise.
        * pathname.h: Likewise.
        * progname.h: Likewise.
        * stpcpy.h: Likewise.
        * stpncpy.h: Likewise.
        * strcase.h: Likewise.
        * strstr.h: Likewise.
        * xalloc.h: Likewise.

        * mbswidth.h: Add extern "C" for C++.
        Reported by Albert Chin-A-Young <address@hidden>.

*** backupfile.h        18 Jun 2003 05:52:19 -0000      1.12
--- backupfile.h        16 Jul 2004 16:27:40 -0000
***************
*** 1,6 ****
  /* backupfile.h -- declarations for making Emacs style backup file names
  
!    Copyright (C) 1990, 1991, 1992, 1997, 1998, 1999, 2003 Free
     Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,6 ----
  /* backupfile.h -- declarations for making Emacs style backup file names
  
!    Copyright (C) 1990, 1991, 1992, 1997, 1998, 1999, 2003, 2004 Free
     Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 21,26 ****
--- 21,31 ----
  #ifndef BACKUPFILE_H_
  # define BACKUPFILE_H_
  
+ # ifdef __cplusplus
+ extern "C" {
+ # endif
+ 
+ 
  /* When to make backup files. */
  enum backup_type
  {
***************
*** 51,54 ****
--- 56,64 ----
  enum backup_type xget_version (char const *context, char const *arg);
  void addext (char *, char const *, int);
  
+ 
+ # ifdef __cplusplus
+ }
+ # endif
+ 
  #endif /* ! BACKUPFILE_H_ */
*** closeout.h  20 Jul 2003 15:49:08 -0000      1.6
--- closeout.h  16 Jul 2004 16:27:40 -0000
***************
*** 1,6 ****
  /* Close standard output.
  
!    Copyright (C) 1998, 2000, 2003 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
--- 1,6 ----
  /* Close standard output.
  
!    Copyright (C) 1998, 2000, 2003, 2004 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
***************
*** 19,25 ****
--- 19,33 ----
  #ifndef CLOSEOUT_H
  # define CLOSEOUT_H 1
  
+ # ifdef __cplusplus
+ extern "C" {
+ # endif
+ 
  void close_stdout_set_file_name (const char *file);
  void close_stdout (void);
  
+ # ifdef __cplusplus
+ }
+ # endif
+ 
  #endif
*** copy-file.h 28 Mar 2003 21:53:34 -0000      1.1
--- copy-file.h 16 Jul 2004 16:27:40 -0000
***************
*** 16,24 ****
--- 16,35 ----
     along with this program; if not, write to the Free Software Foundation,
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  /* Copy a regular file: from src_filename to dest_filename.
     The destination file is assumed to be a backup file.
     Modification times, owner, group and access permissions are preserved as
     far as possible.
     Exit upon failure.  */
  extern void copy_file_preserving (const char *src_filename, const char 
*dest_filename);
+ 
+ 
+ #ifdef __cplusplus
+ }
+ #endif
*** findprog.h  10 Apr 2003 20:22:51 -0000      1.1
--- findprog.h  16 Jul 2004 16:27:40 -0000
***************
*** 16,21 ****
--- 16,27 ----
     along with this program; if not, write to the Free Software Foundation,
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  /* Look up a program in the PATH.
     Attempt to determine the pathname that would be called by execlp/execvp
     of PROGNAME.  If successful, return a pathname containing a slash
***************
*** 25,27 ****
--- 31,38 ----
     execl/execv on the returned pathname.
     The returned string is freshly malloc()ed if it is != PROGNAME.  */
  extern const char *find_in_path (const char *progname);
+ 
+ 
+ #ifdef __cplusplus
+ }
+ #endif
*** full-write.h        22 Nov 2002 16:25:53 -0000      1.2
--- full-write.h        16 Jul 2004 16:27:40 -0000
***************
*** 1,6 ****
  /* An interface to write() that writes all it is asked to write.
  
!    Copyright (C) 2002 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
--- 1,6 ----
  /* An interface to write() that writes all it is asked to write.
  
!    Copyright (C) 2002-2003 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
***************
*** 18,24 ****
--- 18,35 ----
  
  #include <stddef.h>
  
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  /* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted
     or if partial writes occur.  Return the number of bytes successfully
     written, setting errno if that is less than COUNT.  */
  extern size_t full_write (int fd, const void *buf, size_t count);
+ 
+ 
+ #ifdef __cplusplus
+ }
+ #endif
*** pathname.h  28 Apr 2004 11:26:25 -0000      1.2
--- pathname.h  16 Jul 2004 16:27:40 -0000
***************
*** 18,23 ****
--- 18,28 ----
  #ifndef _PATHNAME_H
  #define _PATHNAME_H
  
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  /* Pathname support.
     ISSLASH(C)           tests whether C is a directory separator character.
     IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
***************
*** 47,50 ****
--- 52,59 ----
  extern char *concatenated_pathname (const char *directory,
                                    const char *filename, const char *suffix);
  
+ #ifdef __cplusplus
+ }
+ #endif
+ 
  #endif /* _PATHNAME_H */
*** progname.h  22 Aug 2003 13:56:32 -0000      1.2
--- progname.h  16 Jul 2004 16:27:40 -0000
***************
*** 1,5 ****
  /* Program name management.
!    Copyright (C) 2001-2003 Free Software Foundation, Inc.
     Written by Bruno Haible <address@hidden>, 2001.
  
     This program is free software; you can redistribute it and/or modify
--- 1,5 ----
  /* Program name management.
!    Copyright (C) 2001-2004 Free Software Foundation, Inc.
     Written by Bruno Haible <address@hidden>, 2001.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 25,30 ****
--- 25,36 ----
       set_program_name (argv[0]);
   */
  
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  /* String containing name the program is called with.  */
  extern const char *program_name;
  
***************
*** 47,50 ****
--- 53,62 ----
  
  #endif
  
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ 
  #endif /* _PROGNAME_H */
*** stpcpy.h    15 Jan 2003 12:45:54 -0000      1.2
--- stpcpy.h    16 Jul 2004 16:27:40 -0000
***************
*** 25,33 ****
--- 25,41 ----
  
  #else
  
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
  /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
  extern char *stpcpy (char *dst, const char *src);
  
+ #ifdef __cplusplus
+ }
+ #endif
+ 
  #endif
  
  #endif /* _STPCPY_H */
*** stpncpy.h   26 Sep 2003 15:25:30 -0000      1.2
--- stpncpy.h   16 Jul 2004 16:27:40 -0000
***************
*** 1,5 ****
  /* String copying.
!    Copyright (C) 1995, 2001-2003 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
--- 1,5 ----
  /* String copying.
!    Copyright (C) 1995, 2001-2004 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
***************
*** 20,25 ****
--- 20,31 ----
  
  #include <string.h>
  
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  #if !HAVE_STPNCPY
  
  /* Copy no more than N bytes of SRC to DST, returning a pointer past the
***************
*** 31,34 ****
--- 37,46 ----
  
  #endif
  
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ 
  #endif /* _STPNCPY_H */
*** strcase.h   15 Jan 2003 12:45:54 -0000      1.2
--- strcase.h   16 Jul 2004 16:27:40 -0000
***************
*** 20,25 ****
--- 20,31 ----
  
  #include <stddef.h>
  
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ 
  /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
     greater than zero if S1 is lexicographically less than, equal to or greater
     than S2.
***************
*** 32,35 ****
--- 38,47 ----
     Note: This function can not work correctly in multibyte locales.  */
  extern int strncasecmp (const char *s1, const char *s2, size_t n);
  
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ 
  #endif /* _STRCASE_H */
*** strstr.h    15 Nov 2002 17:35:33 -0000      1.2
--- strstr.h    16 Jul 2004 16:27:40 -0000
***************
*** 1,5 ****
  /* Searching in a string.
!    Copyright (C) 2001, 2002 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
--- 1,5 ----
  /* Searching in a string.
!    Copyright (C) 2001-2003 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
***************
*** 22,28 ****
--- 22,36 ----
  
  #else
  
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
  /* Find the first occurrence of NEEDLE in HAYSTACK.  */
  extern char *strstr (const char *haystack, const char *needle);
  
+ #ifdef __cplusplus
+ }
+ #endif
+ 
  #endif
*** xalloc.h    13 Nov 2003 07:19:09 -0000      1.24
--- xalloc.h    16 Jul 2004 16:27:40 -0000
***************
*** 1,7 ****
  /* xalloc.h -- malloc with out-of-memory checking
  
     Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2003 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
--- 1,7 ----
  /* xalloc.h -- malloc with out-of-memory checking
  
     Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2003, 2004 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
***************
*** 22,27 ****
--- 22,33 ----
  
  # include <stddef.h>
  
+ 
+ # ifdef __cplusplus
+ extern "C" {
+ # endif
+ 
+ 
  # ifndef __attribute__
  #  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
  #   define __attribute__(x)
***************
*** 32,37 ****
--- 38,44 ----
  #  define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
  # endif
  
+ 
  /* If this pointer is non-zero, run the specified function upon each
     allocation failure.  It is initialized to zero. */
  extern void (*xalloc_fail_func) (void);
***************
*** 84,87 ****
--- 91,100 ----
  # define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type))
  # define XFREE(p) free (p)
  
+ 
+ # ifdef __cplusplus
+ }
+ # endif
+ 
+ 
  #endif /* !XALLOC_H_ */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]