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:

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:

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
Post a Comment