I have tried this code in a totally separate project, and it works fine (the only difference being that the project that is not working is being exported as a DLL). Here is
The problem in my case was a Debug configuration with Runtime Library
set to Multi-threaded DLL
. The fix was to change it to Multi-threaded Debug DLL
. The error is gone. Removing _DEBUG
macro was also a kind of workaround, by I guess it's not a good idea because you end up with debug build linked to non-debug standard library.