c++ mutex header and windows header conflicts

Hi,

When I try to include the header of mutex (#include <mutex>) after the windows one(#include <Windows.h>), all windows variables get destroyed, and the compilers gives out errors that STD:: functions are not defined.

How can I solve this?

Thank you,

Gomitung
This doesn't make any sense OP. Let's start with you telling us what version of which IDE you are using.

EDIT: Your code would help to if you don't mind. That way we will be able to see what you are trying to call.
Last edited on
The code is:
1
2
3
4
#include <mutex>
#include <Windows.h>
std::mutex mtx;
HWND hwnd;


HWND is not defined.
Like I said, we should start with the name and version of the IDE and compiler that you are using. This will tell us if this particular C++x11 feature is supported or not. If it is not, then that would at least explain the issue that you are seenig. In that case the WinAPI still has it's own version of a Mutex that you may be able to use instead.
Last edited on
Microsoft Visual Studio 2013
I have VS2013 Express and cannot confirm your problem in a new blank project.
I'm glad I'm not the only one.

@ OP: HWND is defined in 'Windef.h' which should be brought in from a relative directory when you include 'Windows.h'. Do you have a current Windows SDK in your search path or are you trying to include this using only literal paths that you cut out when you posted this here?
Yes, if I remove the include of the mutex and the std::mutex variable, the HWND works.
Try reinstalling your compiler and make sure any other compilers (e.g. MinGW) are not in your system path when you try again (I usually just rename the MinGW folder with a dash at the end).
Thanks! That solved it!
Topic archived. No new replies allowed.