-1

C++/CLI is known to block the mutex header when a project is compiled using the -clr:pure or clr flag. The error is reported here https://social.msdn.microsoft.com/Forums/vstudio/en-US/d4d082ff-ce43-478d-8386-0effed04b108/ccli-and-stdmutex?forum=vclanguage

The recommended solution seems to be to use the pimpI pattern. See here Turn off clr option for header file with std::mutex

The problem I see is when using other std functions. For example consider the std::condition_variable

mutexPimpI _mut;
std::unique_lock<mutexPimpI> lk(_mut); //Fine std::unique_lock is templated.
std::condition_variable _gate1;
_gate1.wait(lk); //Error wait expects std::unique_lock<std::mutex> as argument

Is there any easy way to resolve / work around this problem?

Johan
  • 462
  • 2
  • 14

2 Answers2

0

you can try using recursive__mutex class since objects wont be locked. https://msdn.microsoft.com/en-us/library/hh921466.aspx refer this as well.

AlSeEcS
  • 1
  • 1
  • The problem is you are not allowed to at all include mutex if you compile with -clr:pure flag. – Johan Dec 08 '17 at 11:45
0

I solved it by forward declare std::condition_variable. The problem with Visual Studio's compiler for mutex includes is only for headers. Including in the source files still worked.

Johan
  • 462
  • 2
  • 14