if you have something like this:
int _tmain(int argc, _TCHAR* argv[]) {
int i;
#if (num>99)
i = func();
#else
i= func2();
#endif
return 0;
}
static int func()
{
return 1;
}
static int func2()
{
return 2;
}
Is it reasonable to expect that depending on if num
is bigger or smaller then 99 ether func
or func2
will be removed from the runtime code?
Or would I rather need to also embed the functions in an #if
to achieve this goal?
This depends on linker,what does it with dead code is linker specific.
You should also include function definition under #if
to make sure that it wont results into machine code.
It depends on optimization level. On linux you can check it youself using
readelf -s ./a.out | grep func2
But I think you use windows, so you need some similar tool http://www.pe-explorer.com/ for example.
Here is list of tools: Any tool/software in windows for viewing ELF file format?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With