我试图在Ubuntu 20.0.4 LTS上构建Berkley Db 4.8.30
这就是我迄今为止所做的:
wget http://download.oracle.com/berkeley-db/db-4.8.30.zip
unzip db-4.8.30.zip
cd db-4.8.30
cd build_unix/
../dist/configure --prefix=/usr/local --enable-cxx
make
make install在编译过程中,我得到了错误消息:
错误:“int __atomic_compare_exchange(db_atomic_t*,atomic_value_t,atomic_value_t)”的定义将内置声明“bool__atomic_compare_exchange”(长时间无符号int,易失符号int*,int,int)定义为歧义。
编译标志为我的平台正确设置。以下是代码的相关部分:
原子h(截断)
#if defined(DB_WIN32)
typedef DWORD atomic_value_t;
#else
typedef int32_t atomic_value_t;
#endif
/*
* Windows CE has strange issues using the Interlocked APIs with variables
* stored in shared memory. It seems like the page needs to have been written
* prior to the API working as expected. Work around this by allocating an
* additional 32-bit value that can be harmlessly written for each value
* used in Interlocked instructions.
*/
#if defined(DB_WINCE)
typedef struct {
volatile atomic_value_t value;
volatile atomic_value_t dummy;
} db_atomic_t;
#else
typedef struct {
volatile atomic_value_t value;
} db_atomic_t;
#endif
#define atomic_compare_exchange(env, p, o, n) \
__atomic_compare_exchange((p), (o), (n))
/*
* x86/gcc Compare exchange for shared latches. i486+
* Returns 1 for success, 0 for failure
*
* GCC 4.1+ has an equivalent __sync_bool_compare_and_swap() as well as
* __sync_val_compare_and_swap() which returns the value read from *dest
* http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
* which configure could be changed to use.
*/
static inline int __atomic_compare_exchange(
db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
{
atomic_value_t was;
if (p->value != oldval) /* check without expensive cache line locking */
return 0;
__asm__ __volatile__("lock; cmpxchgl %1, (%2);"
:"=a"(was)
:"r"(newval), "r"(p), "a"(oldval)
:"memory", "cc");
return (was == oldval);
}我想我需要设置一个实用程序来忽略类型的安全检查.但不太确定。如何解决此编译错误?
发布于 2021-02-07 23:48:13
功能
bool __atomic_compare_exchange(long unsigned int, volatile void*, void*, void*, int, int)是一个内置的用于原子操作的GCC编译器函数.详见此处:
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
功能
int __atomic_compare_exchange(db_atomic_t*, atomic_value_t, atomic_value_t)似乎是Berkley 4.8.30的一个函数,这会造成冲突。没有两个函数可以有相同的名称。
下面的链接是可以应用于解决问题的修补程序(包括补丁说明)的链接:
https://stackoverflow.com/questions/66053355
复制相似问题