c++ - __transaction_atomic 未启用事务内存支持

标签 c++ gcc locking atomic transactional-memory

我只是使用 __transaction_atomic 编译 C/C++ 代码,但出现了编译器错误

  • [错误] __transaction_atomic' 未启用事务内存支持

代码是:

#include <stdio.h>
int main()
{
    int i = 0;
    __transaction_atomic
    {
        i++;
    }
    return 0;
}

如何解决?我的编译器是 GCC 4.9

最佳答案

您应该在启用事务内存支持的情况下编译代码。 From here

Compiling a TM program with GCC To enable the support for TM, the '-fgnu-tm' compiler directive has to be added to the compilation command line. Example: gcc -Wall -fgnu-tm -O3 -o ll ll.c Note that with the optimization level 0 (-O0), some of the TM optimization are disabled (RaR, RaW, RfW, WaR, WaW, optimized stack memory barriers).

关于c++ - __transaction_atomic 未启用事务内存支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34449822/

相关文章:

c++ - 如何在一个 JsonArray 中添加多个 json 字符串?

c++ - Qt cpp - 将 QString 写入文本文件的简洁方法

c++ - Valgrind 报告不匹配的 free()/delete/delete []

c++ - 如何拒绝 MSVC 自己包含 header

java - 监视 Java 应用程序上的锁争用

c# - MFC中有没有类似DataGridView的控件

C++ - 查找两个范围的交集

c - 为什么在 glibc libc-lock.h 中使用三个 *?

java - 通过运行对象的同步方法来获取对象的锁

sql - 检查 SQL Server 2005 中的 KEYLOCK