Menu

How does shadowVariable work for member variables?

2024-07-22
2024-07-22
  • Sander Bouwhuis

    Sander Bouwhuis - 2024-07-22

    I get the following error for my code:
    Id: shadowVariable
    CWE: 398
    Local variable 'm_u64TickCountStart' shadows outer variable

    m_u64TickCountStart is a member variable of my CLauncher class.
    This is my code:

    // This functions shows the dialog
    void CLauncher::ShowDialog(std::wstring *pWstrDebugLog, HINSTANCE hInst, bool bForceNewLicense, const CCmdLineParams &cmdLineParams)
    {
      // Set the debug log
      m_pWstrDebugLog = pWstrDebugLog;
    
      ENTER_FUNCTION_DEBUG_LOG_TO_MEM
    
      try
      {
        CHECK_MEM_LEAKS
    
        // Initialize the variables
        m_u64TickCountStart = GetTickCount64();
    
        // ...
      }
      catch(...) { OnException(m_pWstrDebugLog, __FILE__, __LINE__, __FUNCSIG__, __TIMESTAMP__, nullptr); }
    }
    

    What does the error signify? What am I doing wrong?

     

    Last edit: Sander Bouwhuis 2024-07-22
  • CHR

    CHR - 2024-07-22

    Please post a self-contained example which reproduces the issue.
    How is m_u64TickCountStart declared? Are those macros like CHECK_MEM_LEAKS defined/visible to cppcheck?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.