warning: compound assignment with 'volatile'-qualified left operand is deprecated

157 views Asked by At

I have some c++ project in my hands, before this problem arrive i have c++17 flag in my makefile after i tried c++20 this warnings shows up.

After a short look i dont understand what is the problem, after a C++20 flag this what i get from compiler ;

main.cpp: In function 'void heartbeat(LPHEART, int)':
main.cpp:185:20: warning: compound assignment with 'volatile'-qualified left operand is deprecated [-Wvolatile]

This is the code cause of the warning ;

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, 0, &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, 0, &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(), c_set_desc.end(), ::DisconnectFunc());
        }
        else if (thecore_pulse() > g_shutdown_disconnect_force_pulse + PASSES_PER_SEC(5))
        {
            thecore_shutdown();
        }
    }
}

What should i do for beat this warning ? Best regards.

0

There are 0 answers