diff --git a/build_windows/VS10/db.vcxproj b/build_windows/VS10/db.vcxproj index 2fd172d6f..b4c784d86 100644 --- a/build_windows/VS10/db.vcxproj +++ b/build_windows/VS10/db.vcxproj @@ -335,6 +335,10 @@ + + + + diff --git a/build_windows/VS10/db_small.vcxproj b/build_windows/VS10/db_small.vcxproj index 3c67d5728..565561c48 100644 --- a/build_windows/VS10/db_small.vcxproj +++ b/build_windows/VS10/db_small.vcxproj @@ -303,6 +303,10 @@ + + + + diff --git a/build_windows/VS8/db.vcproj b/build_windows/VS8/db.vcproj index a0bf7bd1c..8afbd58ea 100644 --- a/build_windows/VS8/db.vcproj +++ b/build_windows/VS8/db.vcproj @@ -279,6 +279,10 @@ + + + + diff --git a/build_windows/VS8/db_small.vcproj b/build_windows/VS8/db_small.vcproj index 3bbb9e269..528a351f4 100644 --- a/build_windows/VS8/db_small.vcproj +++ b/build_windows/VS8/db_small.vcproj @@ -236,6 +236,10 @@ + + + + diff --git a/build_windows/db.h b/build_windows/db.h index d421edc1d..ddf07507f 100644 --- a/build_windows/db.h +++ b/build_windows/db.h @@ -2809,16 +2809,21 @@ typedef struct { * * The global variables dbrdonly, dirf and pagf were not retained when 4BSD * replaced the dbm interface with ndbm, and are not supported here. + * + * These unprefixed 4BSD names (delete, fetch, firstkey, nextkey, store, ...) + * are C-only historic aliases: they collide with C++ keywords and standard + * library member names (e.g. std::atomic<>::store, which MSVC's + * pulls into any C++ translation unit). Suppress them for C++. */ +#if !defined(__cplusplus) #define dbminit(a) __db_dbm_init(a) #define dbmclose __db_dbm_close -#if !defined(__cplusplus) #define delete(a) __db_dbm_delete(a) -#endif #define fetch(a) __db_dbm_fetch(a) #define firstkey __db_dbm_firstkey #define nextkey(a) __db_dbm_nextkey(a) #define store(a, b) __db_dbm_store(a, b) +#endif /******************************************************* * Hsearch historic interface. diff --git a/src/dbinc/atomic.h b/src/dbinc/atomic.h index ae994fa21..1cc3d10a5 100644 --- a/src/dbinc/atomic.h +++ b/src/dbinc/atomic.h @@ -108,7 +108,16 @@ typedef struct { * Modification operations delegate to ENV-aware functions. */ #define atomic_read(p) __os_atomic_read(p) +/* + * atomic_init collides with the C++ free function std::atomic_init + * (and C11 atomic_init). MSVC's C++ standard library pulls + * into any C++ translation unit, and the macro would rewrite that + * declaration -> compile failure. Berkeley DB only calls atomic_init() from + * C sources, so define the macro only for C. + */ +#if !defined(__cplusplus) #define atomic_init(p, val) __os_atomic_init((p), (val)) +#endif /* * atomic_read_relaxed: torn-read-free load with no ordering, for pure diff --git a/src/dbinc/db.in b/src/dbinc/db.in index b8a24e623..e7a00974f 100644 --- a/src/dbinc/db.in +++ b/src/dbinc/db.in @@ -2778,16 +2778,21 @@ typedef struct { * * The global variables dbrdonly, dirf and pagf were not retained when 4BSD * replaced the dbm interface with ndbm, and are not supported here. + * + * These unprefixed 4BSD names (delete, fetch, firstkey, nextkey, store, ...) + * are C-only historic aliases: they collide with C++ keywords and standard + * library member names (e.g. std::atomic<>::store, which MSVC's + * pulls into any C++ translation unit). Suppress them for C++. */ +#if !defined(__cplusplus) #define dbminit(a) __db_dbm_init@DB_VERSION_UNIQUE_NAME@(a) #define dbmclose __db_dbm_close@DB_VERSION_UNIQUE_NAME@ -#if !defined(__cplusplus) #define delete(a) __db_dbm_delete@DB_VERSION_UNIQUE_NAME@(a) -#endif #define fetch(a) __db_dbm_fetch@DB_VERSION_UNIQUE_NAME@(a) #define firstkey __db_dbm_firstkey@DB_VERSION_UNIQUE_NAME@ #define nextkey(a) __db_dbm_nextkey@DB_VERSION_UNIQUE_NAME@(a) #define store(a, b) __db_dbm_store@DB_VERSION_UNIQUE_NAME@(a, b) +#endif /******************************************************* * Hsearch historic interface. diff --git a/src/os/os_atomic.c b/src/os/os_atomic.c index 8b9c2ca88..8a50aa176 100644 --- a/src/os/os_atomic.c +++ b/src/os/os_atomic.c @@ -1895,6 +1895,15 @@ __os_atomic_thread_fence() !defined(HAVE_ATOMIC_GCC_BUILTIN) && \ !defined(HAVE_ATOMIC_SYNC_BUILTIN) +/* + * The Interlocked* intrinsics take a `LONG volatile *`. We cast the address + * of db_atomic_t::value to that type through `interlocked_val` (matching + * mut_win32.c); it was referenced here but never defined for this TU. + */ +#ifndef interlocked_val +#define interlocked_val long volatile * +#endif + /* * __os_atomic_init -- * Initialize an atomic variable (Windows).