c++ - Turn off clr option for header file with std::mutex -


i have visual studio project contains files managed code , files unmanaged code. project has clr support, when add file not need .net turn off /crl option right-click on file:

enter image description here

i added class has contain unmanaged code , use std::mutex.

// foo.h class foo {    std::mutex m; } 

i got following error after compiling:

error c1189: #error : not supported when compiling /clr or /clr:pure.

the problem not have option turn off clr header files (.h), since window when right-click on .h file:

enter image description here

how can fix problem?

there possibility use workaround known pointer implementation (pimpl) idiom.

following brief example:

// foo.h #include <memory>  class foo { public:    foo();    // forward declaration nested type   struct mstr;   std::unique_ptr<mstr> impl; };   // foo.cpp #include <mutex>  struct foo::mstr {   std::mutex m; };  foo::foo()   : impl(new mstr()) { } 

Comments