64,682
社区成员
发帖
与我相关
我的任务
分享
#include <atomic>
#include <iostream>
#include <memory>
using namespace std;
struct AppleD {
int color = 0;
int weight = 3;
int size = 5;
};
int main() {
AppleD b;
atomic<AppleD> a(b);
cout << (a.load()).size << endl;
return 0;
}
yang@yanghuang:~/Code/Study$ g++ test.cpp -g -Wall -std=c++11 -o main
/tmp/ccw4rjp1.o:在函数‘std::atomic<AppleD>::load(std::memory_order) const’中:
/usr/include/c++/7/atomic:250:对‘__atomic_load’未定义的引用
collect2: error: ld returned 1 exit status
yang@yanghuang:~/Code/Study$ g++-9 test.cpp -g -Wall -std=c++11 -o test
/tmp/cc7h2YAe.o:在函数‘std::atomic<AppleD>::load(std::memory_order) const’中:
/usr/include/c++/9/atomic:254:对‘__atomic_load’未定义的引用
collect2: error: ld returned 1 exit status