From: Steve Peters Date: Mon, 9 Oct 2006 20:17:07 +0000 (+0000) Subject: Make g++ happy when compiling NDBM_File on a system that X-Git-Tag: accepted/trunk/20130322.191538~16899 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e82f3e3c5fa2a46d2475b54a3790ddd631719562;p=platform%2Fupstream%2Fperl.git Make g++ happy when compiling NDBM_File on a system that is likely using the GDBM compatibility headers that g++ (and other C++ implementations) cannot handle. p4raw-id: //depot/perl@28976 --- diff --git a/ext/NDBM_File/Makefile.PL b/ext/NDBM_File/Makefile.PL index 7b58601..dc5cc44 100644 --- a/ext/NDBM_File/Makefile.PL +++ b/ext/NDBM_File/Makefile.PL @@ -1,7 +1,16 @@ +use Config; use ExtUtils::MakeMaker; + +my $define = ""; + +if($Config{i_gdbm} && $Config{i_gdbm} eq 'define') { + $define .= " -DHAS_GDBM"; +} + WriteMakefile( NAME => 'NDBM_File', LIBS => ["-L/usr/local/lib -lndbm", "-ldbm -lucb"], + DEFINE => $define, MAN3PODS => {}, # Pods will be built by installman. XSPROTOARG => '-noprototypes', # XXX remove later? VERSION_FROM => 'NDBM_File.pm', diff --git a/ext/NDBM_File/NDBM_File.xs b/ext/NDBM_File/NDBM_File.xs index 5e02af7..0c726cf 100644 --- a/ext/NDBM_File/NDBM_File.xs +++ b/ext/NDBM_File/NDBM_File.xs @@ -16,6 +16,20 @@ typedef NDBM_File_type * NDBM_File ; typedef datum datum_key ; typedef datum datum_value ; + +#if defined(_cplusplus) && defined(HAS_GDBM) +/* gdbm's header file used for compatibility with gdbm */ +/* isn't compatible to C++ syntax, so we need these */ +/* declarations to make everyone happy. */ +EXTERN_C DBM *dbm_open(const char *, int, mode_t); +EXTERN_C void dbm_close(DBM *); +EXTERN_C datum dbm_fetch(DBM *, datum); +EXTERN_C int dbm_store(DBM *, datum, datum, int); +EXTERN_C int dbm_delete(DBM *, datum); +EXTERN_C datum dbm_firstkey(DBM *); +EXTERN_C datum dbm_nextkey(DBM *); +#endif + MODULE = NDBM_File PACKAGE = NDBM_File PREFIX = ndbm_ NDBM_File