Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<mutex>: std::mutex not declared when included from C++/CLI #980

Closed
Chronial opened this issue Jul 3, 2020 · 3 comments · Fixed by #3194
Closed

<mutex>: std::mutex not declared when included from C++/CLI #980

Chronial opened this issue Jul 3, 2020 · 3 comments · Fixed by #3194
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@Chronial
Copy link
Contributor

Chronial commented Jul 3, 2020

std::mutex is not declared by <mutex> when the header is included from C++/CLI.

I assume the reason for this is that the implementation is somehow incompatible with C++/CLI? Could this maybe be fixed by using #pragma managed(push, off) around problematic parts?

Even if this is not possible, the current solution has unfortunate side effects: We have a header that defines a C++ class that has a std::mutex as its member. Even though all interactions with that member are implemented in native code, C++/CLI code not interact with this class because the header doesn't compile under C++/CLI.

See also #838

Workaround: std::shared_mutex is available under C++/CLI.

@Chronial Chronial changed the title <mutex>: std::mutex not declared when included from C++/CLI <mutex> std::mutex not declared when included from C++/CLI Jul 3, 2020
@Chronial Chronial changed the title <mutex> std::mutex not declared when included from C++/CLI <mutex>: std::mutex not declared when included from C++/CLI Jul 3, 2020
@Chronial
Copy link
Contributor Author

Chronial commented Jul 3, 2020

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Jul 3, 2020
@NorbertNemec
Copy link

I just stumbled over the same issue. @StephanTLavavej could you please clarify - is this a bug expected to be fixed by providing std::mutex when building with /clr? According to an old post from 2014 https://stackoverflow.com/questions/26585714/error-mutex-is-not-supported-when-compiling-with-clr-or-clrpure there used to be something more fundamental behind this. Has that been resolved meanwhile?

@NorbertNemec
Copy link

Following #838 I realized that I can easily work around this by using shared_mutex, so it is not a pressing matter for me after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants