Breakpoints do not get hit in functions with arguments

I’m writing a C++ code for ActorComponent. When I’m trying to debug function in Visual Studio breakpoints in functions that have arguments do not get hit. Neither can i step into these functions.
for example function:

void UInventorySystem::TestFunctionForDebugger()
{
    for (int i = 0; i < 5; i++)
    {
        UE_LOG(LogTemp, Log, TEXT("The value of int is: %d"), i);
    }
}

Debugs fine. But once i add an argument

void UInventorySystem::TestFunctionForDebugger(int test_int)
{
    for (int i = 0; i < test_int; i++)
    {
        UE_LOG(LogTemp, Log, TEXT("The value of int is: %d"), i);
    }
}

Breakpoints do not get hit.

It’s probably due to compiler optimizations. You can disable them in your build file

// PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; // <= comment out

// Do not use PCH or Unity builds,
PCHUsage = ModuleRules.PCHUsageMode.NoPCHs;
// Nor Optimization, since intrinsics clash with those options :/
OptimizeCode = CodeOptimization.Never;

Just make sure to enable them before you pack & ship your game.

I see. Just fixed by adding #pragma optimize("", off) in top of cpp file. I assume your method turns off optimization for the entire project?

Yes. It’s probably easier to control on a project level then hunt down many temporary setups per file.

For some reason adding this to Build.cs broke the project. When i’m trying to build it throws lots of errors that i haven’t seen before like this one:
InventorySystem.h(23): error C2143: syntax error: missing ';' before '*'

fixed by adding some #includes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.