内联程序集发生Clang错误
Clang error with inline assembly
1 #ifndef ATOMIC_UTILS_H
2 #define ATOMIC_UTILS_H
3
4 #include<cstddef>
5
6 class AtomicUtils
7 {
8 public:
9
10 /**
11 * check if the value at addr is equal to oldval, if so replace it with newval
12 * and return the oldval
13 */
14 static size_t compareAndExchange( volatile size_t* addr, size_t oldval, size_t newval )
15 {
16 size_t ret;
17 __asm__ volatile( "lock cmpxchgl %2, %1nt"
18 :"=a"(ret), "+m"(*addr)
19 : "r"(newval), "0"(oldval)
20 : "memory" );
21 return ret;
22 }
23 };
24
25 #endif
<>之前在atomics_test.cpp包含的文件中:./atoms .hpp:17:25:错误:指令的操作数无效__asm__ volatile("锁定CMPXCHGL %2, %1nt")^:1:16:注意:在这里实例化为汇编锁定CMPXCHGL %rsi, (%rdx)^ ~ ~ ~ ~之前我完全不知道这个错误。有人能帮帮忙吗??我用的是64位mac book pro,安装了clang。
错误是您正在使用64位值的cmpxchgl (cmpxchgl需要32位值)。
相关文章:
- 获取 clang++:错误:在编译文件系统库的代码时
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 如何修复 clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- "Make"失败并出现 Clang 错误 - 如何从 Clang 获得错误?
- Android NDK.Build命令失败.未定义的引用.clang++:错误:链接器命令失败,退出代码为1
- Clang 错误 – 编译器错误或缺少一些细节?
- 为什么我在以下代码中收到 clang 错误?
- clang:错误:链接器命令失败,C++代码中的退出代码为 1(使用 -v 查看调用)
- NDK Clang 错误:未定义对"localeconv"的引用
- Clang 3.8 错误:参数 '-fuse-ld=gold-2.25' 中的链接器名称无效
- 限定名称和使用声明操作的 clang 错误消息
- 编译模板时的clang错误
- ld:1 个重复符号用于架构x86_64 clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- C /R:clang:错误:Linker命令失败,出口代码1(使用-v查看调用)
- clang错误,没有可行的转换
- gcc 未给出的 Clang 错误"attempted to construct a reference element in a tuple with an rvalue"
- Clang:错误:非静态数据成员的使用无效
- 启用 openmp 时出错 - "ld: library not found for -lgomp" 和 Clang 错误
- 为什么在使用初始化语法时不调用转换运算符,为什么 clang 错误消息看起来是错误的
- 当使用 stdlibc++ 4.7 启用 C++11 时,clang 错误,而 gcc 编译正常