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 .
In comparing the DBM source code in cvs.mozilla.org with the DBM source code in the Netscape internal cvs repository, I noticed what I think is a mistake in the mozilla.org 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.
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". 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.
Status: NEW → ASSIGNED
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 Windows. Can I get a review?
Comment on attachment 52739 [details] [diff] [review] Proposed patch. r=shaver
Attachment #52739 - Flags: review+
Fix checked in on the trunk.
Status: ASSIGNED → RESOLVED
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 -I/builds/tinderbox/SeaMonkey/HP-UX_B.11.00_Clobber/mozilla/dist/include/nspr +Z -DHPUX11 -Dhpux -DNDEBUG -DTRIMMED -DMOZILLA_CLIENT -DNSCAP_DISABLE_DEBUG_PTR_TYPES=1 -DD_INO=d_ino -DMOZ_WIDGET_GTK=1 -DMOZ_ENABLE_XREMOTE=1 -DMOZ_DEFAULT_TOOLKIT=\"gtk\" -DMOZ_X11=1 -DSTDC_HEADERS=1 -DHAVE_ST_BLKSIZE=1 -DHAVE_INT16_T=1 -DHAVE_INT32_T=1 -DHAVE_INT64_T=1 -DHAVE_UINT=1 -DHAVE_UINT_T=1 -DHAVE_UINT16_T=1 -DHAVE_DIRENT_H=1 -DHAVE_SYS_BYTEORDER_H=1 -DHAVE_MEMORY_H=1 -DHAVE_UNISTD_H=1 -DHAVE_NL_TYPES_H=1 -DHAVE_X11_XKBLIB_H=1 -DHAVE_SYS_STATVFS_H=1 -DHAVE_SYS_VFS_H=1 -DHAVE_SYS_MOUNT_H=1 -DHAVE_LIBM=1 -D_REENTRANT=1 ! -DMOZ_OJI _REQUIRE_THREAD_SAFE_ON_STARTUP=1 -DHAVE_RANDOM=1 -DHAVE_STRERROR=1 -DHAVE_LCHOWN=1 -DHAVE_FCHMOD=1 -DHAVE_SNPRINTF=1 -DHAVE_LOCALTIME_R=1 -DHAVE_STATVFS=1 -DHAVE_MEMMOVE=1 -DHAVE_RINT=1 -DHAVE_NL_LANGINFO=1 -DHAVE_STRTOK_R=1 -DHAVE_IOS_BINARY=1 -DHAVE_CPP_EXPLICIT=1 -DHAVE_CPP_SPECIALIZATION=1 -DHAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX=1 -DHAVE_CPP_PARTIAL_SPECIALIZATION=1 -DHAVE_CPP_ACCESS_CHANGING_USING=1 -DHAVE_CPP_AMBIGUITY_RESOLVING_USING=1 -DHAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL=1 -DHAVE_CPP_NEW_CASTS=1 -DHAVE_CPP_DYNAMIC_CAST_TO_VOID_PTR=1 -DNEED_CPP_UNUSED_IMPLEMENTATIONS=1 -DHAVE_I18N_LC_MESSAGES=1 -DMOZ_LOGGING=1 -DMOZ_ENDER_LITE=1 -DNS_MT_SUPPORTED=1 -DIBMBIDI=1 -DACCESSIBILITY=1 -DMOZ_PERF_METRICS=1 -DFORCE_BUILD_REFCNT_LOGGING=1 -DMOZ_USER_DIR=\".mozilla\" -DMOZ_XUL=1 -DINCLUDE_XUL=1 -DMOZ_MATHML=1 -DMOZ_SVG=1 -DUSE_IMG2=1 -DMOZ_BYPASS_PROFILE_AT_STARTUP=1 -DMOZ_DLL_SUFFIX=\".sl\" -DXP_UNIX=1 -DUNIX_ASYNC_DNS=1 -DJS_THREADSAFE=1 TestDBMAccess.cpp 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 */ ^^^^^^^
You need to log in before you can comment on or make changes to this bug.