bug-gnu-utils
[Top][All Lists]
Advanced

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

GDBM - ndbm.h and C++


From: Michal Rokos
Subject: GDBM - ndbm.h and C++
Date: Thu, 20 Mar 2003 13:43:42 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312

Hi,

        I had some problems to compile sources that used gdbm-ndbm.h with C++.

        Patch (attached) solves it.

        Please concider to merge this.

        Thank you.

                Michal Rokos
--- ndbm.h.orig 2002-09-17 21:36:35.000000000 +0200
+++ ndbm.h      2003-03-20 13:19:03.000000000 +0100
@@ -25,47 +25,54 @@
                 Bellingham, WA 98226
        
 *************************************************************************/
+/* Protection for multiple includes. */
+#ifndef _NDBM_H_
+#define _NDBM_H_
 
 /* Parameters to dbm_store for simple insertion or replacement. */
 #define  DBM_INSERT  0
 #define  DBM_REPLACE 1
 
-
 /* The data and key structure.  This structure is defined for compatibility. */
 typedef struct {
        char *dptr;
        int   dsize;
       } datum;
 
-
 /* The file information header. This is good enough for most applications. */
 typedef struct {int dummy[10];} DBM;
 
+/* Determine if the C(++) compiler requires complete function prototype  */
+#ifndef __P
+#if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#define __P(x) x
+#else
+#define __P(x) ()
+#endif
+#endif
+
+/* NDBM C++ support */
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
 
 /* These are the routines (with some macros defining them!) */
 
-extern DBM     *dbm_open ();
-
-extern void     dbm_close ();
-
-extern datum    dbm_fetch ();
-
-extern int      dbm_store ();
-
-extern int      dbm_delete ();
-
-extern int      dbm_delete ();
-
-extern datum    dbm_firstkey ();
-
-extern datum    dbm_nextkey ();
-
-#define                 dbm_error(dbf)  (0)
-
-#define                 dbm_clearerr(dbf)
-
-extern int      dbm_dirfno ();
-
-extern int      dbm_pagfno ();
+extern DBM *dbm_open __P((char *, int, int));
+extern void dbm_close __P((DBM *));
+extern datum dbm_fetch __P((DBM *, datum));
+extern int dbm_store __P((DBM *, datum, datum, int));
+extern int dbm_delete __P((DBM *, datum));
+extern datum dbm_firstkey __P((DBM *));
+extern datum dbm_nextkey __P((DBM *));
+#define dbm_error(dbf)  ((void)0)
+#define dbm_clearerr(dbf) ((void)0)
+extern int dbm_dirfno __P((DBM *));
+extern int dbm_pagfno __P((DBM *));
+extern int dbm_rdonly __P((DBM *));
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
 
-extern int      dbm_rdonly ();
+#endif

reply via email to

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