In my Memory.hpp file, I have a namespace boolean named “isMHinit”:
namespace Memory
{
static bool isMHInit = false;
DWORD HookFunction(LPVOID pTarget, LPVOID pDetour, LPVOID pTrampoline, BOOL isWriteCopy);
static UINT64 CheckCodeAccess(UINT64 startaddress);
DWORD OnAccessHookFunction(PVOID pTarget, LPVOID pDetour, LPVOID pTrampoline, BOOL isWriteCopy);
}; // namespace Memory
And inside Memory.cpp, I use and modify it:
// this function is a member of Memory, I removed most functionality for brevity.
DWORD HookFunction(LPVOID pTarget, LPVOID pDetour, LPVOID pTrampoline, BOOL isWriteCopy)
{
if (!isMHInit) {
if (MH_Initialize() != MH_OK) {
std::cout << "Error: MHInit failed." << "n";
return 1;
}
isMHInit = true;
}
When going through clang-tidy, I get this warning: “Variable ‘isMHInit’ is non-const and globally accessible, consider making it const” even though I clearly modify it inside the function. Is this an issue with clang-tidy or should I modify something in my code?