This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why code size increases after uncommenting some lines?

Hello,
I am a student from germany and I am working on a project with KeilC an uVison. I have a strange problem.
- I get some C-code for a 8051 compatible
- this code has extern linker files
- the current code compiles without errors
- after compiling I see some size-values for DATA,XDATA,PDATA
- if i want to shrink the code by deleting or uncommenting some lines the linker throws errors, because the size of data exceed the restrictions by the linker file.

I do not understand, why the code size increases if I shrink the code? Can some one explain me this issue?

Thank you for help,
Regard Chris

Parents
  • Thank you for your answers. I think the problem in my code(the code I am working with, I never wrote that crap) is that some functions are in precompiled libraries and if I am linking against them but only using a few of their functions it happens this what you describe... But how can I get out of? If I am only need these few functions, but haven't the source of these libraries? By the way, I did not get warnings for uncalled functions.

    Thank you for your help,
    Chris

Reply
  • Thank you for your answers. I think the problem in my code(the code I am working with, I never wrote that crap) is that some functions are in precompiled libraries and if I am linking against them but only using a few of their functions it happens this what you describe... But how can I get out of? If I am only need these few functions, but haven't the source of these libraries? By the way, I did not get warnings for uncalled functions.

    Thank you for your help,
    Chris

Children
  • What libraries?

    Good libraries are normally very granular, to make sure the linker can pick up just the needed functions.

  • that some functions are in precompiled libraries and if I am linking against them but only using a few of their functions it happens this what you describe

    If so, that library is constructed incorrectly. It's one of the basic requirements of proper library design to have each independent functional unit in its own translation unit, so it can be left out of the final link if not needed. Basically, a library must have a separate source file for every single data object and function listed in its interface header(s), and another one for each internal functionality used by more than one other.