我只是使用 __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/