Keil Logo

GENERAL: HOW TO STRUCTURE MODULES IN A LIBRARY


Information in this article applies to:

  • C166 Version 4.20
  • C251 Version 3.20
  • C51 Version 6.20

SYMPTOMS

I am trying to create a library of functions, but each time I include it in my applications all the functions in the same file are included even if I do not use them. How should I structure the modules in a library file?

CAUSE

A module (object file) is the smallest translation unit that contains variables, functions, and so on. When the linker extracts variables or functions from a library, the whole module is included (not just the function or variable you use). It is not possible for the linker to extract anything smaller than a module from a library file.

RESOLUTION

While is is not possible for the linker to break a module into smaller blocks, it is possible to do this when creating the source files.

Basically, when creating a library, you should place only one function in a source file. Since each module will contain only one function (or one function and its support variables and routines) additional unused functions will not be included by the linker.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Thursday, December 21, 2006


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.