Why does assigning a function to a struct bloat my binary size?
For some reason when I assign a function to a struct, my compiled binary size jumps up 0.5kb. I know it is the struct causing this because I can use the function in other parts of my code without it jumping up.
The reason I am storing it in a struct anyways is because I need to iterate over some data & find the relevant function to act on that data. Checking every possibility & calling the specific function name from there doesn't sound fun.
I wouldn't mind the 0.5k if it was just that, but I have a ton of little modules each with their own struct instance holding their own separate function & it stacks up quick.
Here is one of my modules so I can show an example of what EXACTLY I am doing that is causing this behavior:
\#pragma once
\#include "../Common.hpp"
\#include "../ScopeState.hpp"
void INST\_End\_exec(const Instruction& inst, const InstToken& token, ScopeState& state, const std::vector<std::string>& args, const std::string& symbol) {
return;
}
Instruction INST\_End {
0,
0,
//INST\_End\_exec,
};
Un-commenting the `//INST_End_exec` line bumps the size, & I'm pretty sure it's not that the compiler was just passing over the function before, because I use it in other parts of my code-base.
I would be really grateful if someone told me why this is the case & if theres an alternative way I can store my functions...