Closed Bug 103881 Opened 20 years ago Closed 20 years ago

mozilla/dbm should include <sys/cdefs.h> rather than <cdefs.h> if HAVE_SYS_CDEFS_H is defined.


(SeaMonkey :: General, defect)

Not set


(Not tracked)



(Reporter: wtc, Assigned: wtc)



(1 file)

In comparing the DBM source code in
with the DBM source code in the Netscape internal
cvs repository, I noticed what I think is a mistake
in the version (<cdefs.h> rather than
<sys/cdefs.h> was included), which led to several
attempts to fix the symptoms (certain macros get
defined twice).  I will attach a patch that fixes
this problem.
Attached patch Proposed patch.Splinter Review
Comments on my proposed patch (attachment 52739 [details] [diff] [review]).

mcom_db.h: this is the file that incorrectly includes <cdefs.h>
if HAVE_SYS_CDEFS_H is defined.  It should include <sys/cdefs.h>.
Because we include <cdefs.h>, we always end up including our
own cdefs.h, which causes multiply-defined macros if <sys/cdefs.h>
also gets included.  I also removed a redundant inclusion of

cdefs.h: this file contains several attempts to work around
the problem of multiply-defined macros.  All of these workarounds
can be removed if we fix the root cause in mcom_db.h.

nsres.h: the inclusion of "cdefs.h" is not necessary because
that is handled by mcom_db.h.

snprintf.c: the inclusion of <sys/cdefs.h> or "cdefs.h" can
be entirely determined by the HAVE_SYS_CDEFS_H macro.

I would appreciate it if you could review my patch.  I will be
testing it on Linux, Mac, and Windows.
The sentence
    Because we include <cdefs.h>, we always end up
    including our own cdefs.h, ...
is not clear enough.  It should read
    Because we include <cdefs.h> and there is no
    /usr/include/cdefs.h on any platforms, we always
    end up including our own cdefs.h, ...
Comment on attachment 52739 [details] [diff] [review]
Proposed patch.

I verified that this patch
works on Mac, Linux, and

Can I get a review?
Fix checked in on the trunk.
Closed: 20 years ago
Resolution: --- → FIXED
cls reported that my patch broke the build on HP-UX 11.00.
I restored the protection for the redefinition of the
macro '__const' in cdefs.h and added a comment.

For future reference, here is the build log:

CC -ext +p -o TestDBMAccess.o -c -DOSTYPE=\"HP-UXB.11\" -DOSARCH=\"HP-UX\" -DOJI
-DUSE_NSREG  -I../../dist/include/xpcom -I../../dist/include/string
-I../../dist/include/necko -I../../dist/include/nkcache
-I../../dist/include/timer -I../../dist/include/cookie -I../../dist/include/dbm
-I../../dist/include/util -I../../dist/include/test_necko -I../../dist/include
Error 129: "../../dist/include/dbm/cdefs.h", line 100 # Redefinition of macro
'__const' differs from previous definition at ["/usr/include/sys/stdsyms.h",
line 332].
    #define __const         const           /* define reserved names to standard */
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.