小编Stu*_*7CB的帖子

Visual Studio 2017 中的 C++ std::mutex lock() 访问冲突

当我尝试运行使用 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)

c++ c++11 visual-studio-2017

5
推荐指数
1
解决办法
4099
查看次数

标签 统计

c++ ×1

c++11 ×1

visual-studio-2017 ×1