More twilight zone?
"Dead code optimisation" is an elite feature, my MikroC is the real old version (long before MikroC "pro") and does not have that feature. Dead code refers to not compiling sections within code that cannot be reached.
What I'm talking about is normal pre-processor activity, that should occur in all C compilers, that check which functions are used and then not compile functions that are never called. The pre-processor in any embedded compiler needs to check all functions, their sizes and frequency of their calls for the purposes of ordering/fitting them neatly in ROM banks etc. So the preprocessor always does a lot of work on functions before compiling anyway, and it's absolutely standard to NOT compile functions if they are never called. It's incredibly simple for any preprocessor to search the code for calls to that function.
This is totally different to dead code!
Dead code; Any code areas that cannot be reached due to the decisions of the code are eliminated, and funcion calls within that code are elminated (which might also eliminate some functions). This requires elite level source code decision/branching analysis.
Normal preprocessor; Checks variables and any time variables are used, eliminates unused variables from compilation and RAM. Checks function calls and functions, if any function is never called it is eliminated from compilation and ROM.
Across many compilers and platforms for many years, I have left unused functions in my code and they have never been compiled.
Maybe the way you are declaring functions in your source or header is forcing the compiler to compile it? Do you have a real world example?
"Dead code optimisation" is an elite feature, my MikroC is the real old version (long before MikroC "pro") and does not have that feature. Dead code refers to not compiling sections within code that cannot be reached.
What I'm talking about is normal pre-processor activity, that should occur in all C compilers, that check which functions are used and then not compile functions that are never called. The pre-processor in any embedded compiler needs to check all functions, their sizes and frequency of their calls for the purposes of ordering/fitting them neatly in ROM banks etc. So the preprocessor always does a lot of work on functions before compiling anyway, and it's absolutely standard to NOT compile functions if they are never called. It's incredibly simple for any preprocessor to search the code for calls to that function.
This is totally different to dead code!
Dead code; Any code areas that cannot be reached due to the decisions of the code are eliminated, and funcion calls within that code are elminated (which might also eliminate some functions). This requires elite level source code decision/branching analysis.
Normal preprocessor; Checks variables and any time variables are used, eliminates unused variables from compilation and RAM. Checks function calls and functions, if any function is never called it is eliminated from compilation and ROM.
Across many compilers and platforms for many years, I have left unused functions in my code and they have never been compiled.
Maybe the way you are declaring functions in your source or header is forcing the compiler to compile it? Do you have a real world example?