当我尝试运行使用 VS2017 编译的可执行文件时,我Exception thrown at 0x00007FFF05BC1063 (msvcp140d.dll) in a.exe: 0xC0000005: Access violation reading location 0x0000000000000000.在启动后立即捕获
。
调试后,我发现当我试图锁定静态互斥锁 _coutMutex 时会发生这种情况。我该如何修复它,因为当我使用 mingw 进行编译时,它运行良好。这是我的代码的一部分:
游戏.hpp:
#include "Logger.hpp"
class Game
{
public:
static Logger logger;
};
Run Code Online (Sandbox Code Playgroud)
游戏.cpp:
#include "Game.hpp"
Logger Game::logger{ "logs/client", Logger::LoggingLevels::Info,
Logger::LoggingLevels::Trace, 2, 100 };
Run Code Online (Sandbox Code Playgroud)
记录器.hpp:
#include <mutex>
class Logger
{
public:
Logger(std::string path, short consoleLoggingLevel, short
fileLoggingLevel, uint32_t count, size_t maxSize);
enum LoggingLevels : short
{
Off = 0,
Fatal = 1,
Error = 2,
Warn = 3,
Info …Run Code Online (Sandbox Code Playgroud)