mardi 12 juillet 2022

Newly installed g++ on wsl has problem recognizing c++11 STL types

Hi: I'm using WSL+Ubuntu20.04 on win10, installed g++ using sudo apt-get.

g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Fairly new, then I have this code modified from cppreference.com:

#include <iostream>
#include <thread>
#include <shared_mutex>
#include <mutex>
using namespace std;

class Counter {
    int value;
    shared_mutex m;
public:
...

My command line is:

g++ rwlock.cpp -std=c++11

It doesn't compile, saying that:

error: ‘shared_mutex’ does not name a type
   10 |     shared_mutex m;

And some other errors, all point to that I don't have these c++11 types defined.

Did I missing anything while installing g++ or should add more command line options when compiling?

Thanks!

Aucun commentaire:

Enregistrer un commentaire