首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:“int__atomic_compare_exchange(Params1)”的定义使内置声明“bool__atomic_compare_exchange(Params2)”成为歧义。

错误:“int__atomic_compare_exchange(Params1)”的定义使内置声明“bool__atomic_compare_exchange(Params2)”成为歧义。
EN

Stack Overflow用户
提问于 2021-02-04 20:28:22
回答 1查看 1.5K关注 0票数 0

我试图在Ubuntu 20.0.4 LTS上构建Berkley Db 4.8.30

这就是我迄今为止所做的:

代码语言:javascript
复制
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(截断)

代码语言:javascript
复制
#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);
}

我想我需要设置一个实用程序来忽略类型的安全检查.但不太确定。如何解决此编译错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-07 23:48:13

功能

代码语言:javascript
复制
bool __atomic_compare_exchange(long unsigned int, volatile void*, void*, void*, int, int)

是一个内置的用于原子操作的GCC编译器函数.详见此处:

https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

功能

代码语言:javascript
复制
int __atomic_compare_exchange(db_atomic_t*, atomic_value_t, atomic_value_t)

似乎是Berkley 4.8.30的一个函数,这会造成冲突。没有两个函数可以有相同的名称。

下面的链接是可以应用于解决问题的修补程序(包括补丁说明)的链接:

https://gist.github.com/danieldk/5700533

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66053355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档