Assume we have the following C code:
void undefined_reference(void);
void bad(void) {
undefined_reference();
}
int main(void) {}
In function bad
we fall into the linker error undefined reference to 'undefined_reference'
, as expected. This function is not actually used anywhere in the code, though, and as such, for the execution of the program, this undefined reference doesn't matter.
Is it possible to compile this code successfully, such that bad
simply gets removed as it is never called (similar to tree-shaking in JavaScript)?