问题描述
我手上有一些 c++ 项目,在这个问题出现之前,我在尝试 c++20 后在我的 makefile 中有 c++17 标志,这个警告出现了。
看了一会儿,我不明白是什么问题,在 C++20 标记之后,我从编译器得到了什么;
main.cpp: In function 'void heartbeat(LPHEART,int)':
main.cpp:185:20: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]
这是警告的代码原因;
volatile int num_events_called = 0;
void heartbeat (LPHEART ht,int pulse)
{
DWORD t;
t = get_dword_time();
num_events_called += event_process (pulse); // LINE 185 IS HERE <<<<<
s_dwProfiler[PROF_EVENT] += (get_dword_time() - t);
t = get_dword_time();
if (!(pulse % ht->passes_per_sec))
{
if (!g_bAuthServer)
{
TPlayerCountPacket pack;
pack.dwCount = DESC_MANAGER::instance().GetLocalUserCount();
db_clientdesc->DBPacket(HEADER_GD_PLAYER_COUNT,&pack,sizeof(TPlayerCountPacket));
}
else
{
DESC_MANAGER::instance().ProcessExpiredLoginKey();
}
{
int count = 0;
if (save_idx < g_vec_save.size())
{
count = MIN(100,g_vec_save.size() - save_idx);
for (int i = 0; i < count; ++i,++save_idx)
db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE,&g_vec_save[save_idx],sizeof(TPlayerTable));
sys_log(0,"SAVE_FLUSH %d",count);
}
}
}
if (!(pulse % (passes_per_sec + 4)))
CHaraCTER_MANAGER::instance().ProcessDelayedSave();
if (!(pulse % (passes_per_sec * 5 + 2)))
{
ITEM_MANAGER::instance().Update();
DESC_MANAGER::instance().UpdateLocalUserCount();
}
s_dwProfiler[PROF_HEARTBEAT] += (get_dword_time() - t);
DBManager::instance().Process();
AccountDB::instance().Process();
CPVPManager::instance().Process();
if (g_bShutdown)
{
if (thecore_pulse() > g_shutdown_disconnect_pulse)
{
const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet();
std::for_each(c_set_desc.begin(),c_set_desc.end(),::SenddisconnectFunc());
g_shutdown_disconnect_pulse = INT_MAX;
}
else if (thecore_pulse() > g_shutdown_disconnect_force_pulse)
{
const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet();
std::for_each(c_set_desc.begin(),::disconnectFunc());
}
else if (thecore_pulse() > g_shutdown_disconnect_force_pulse + PASSES_PER_SEC(5))
{
thecore_shutdown();
}
}
}
我应该怎么做才能打破这个警告?最好的问候。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)