User`s manual

Dynamic C Users Manual digi.com 49
Using compiler directives like #class or #memmap inside module headers is inadvisable. If it is impor-
tant to set, for example, “#class auto” for some library modules and “#class static” for others, the appropri-
ate directives should be placed inside the module body, not in the module header. Furthermore, since there
is no guaranteed compilation order and compiler directives have global scope, when you issue a compiler
directive to change default behavior for a particular module, at the end of the module you should issue
another compiler directive to change back to the default behavior. For example, if a module body needs to
have its storage class as static, have a “#class static” directive at the beginning of the module body and
“#class auto” at the end.
4.23.1.3 Module Body
Every line of code after the EndHeader comment belongs to the body of the module until (1) end-of-file
or (2) the BeginHeader comment of another module. Dynamic C compiles the entire body of a module
if any of the names in the key or header are referenced anywhere in the application. So keep modules
small, don’t put all the functions in a library into one module. If you look at the Dynamic C libraries you’ll
notice that many modules consist of one function. This saves on code size, because only the functions that
are called are actually compiled into the application.
To further minimize waste, define code and data only in the body of a module. It is recommended that a
module header contain only prototypes and extern declarations because they do not generate any code
by themselves. That way, the compiler will generate code or allocate data only if the module is used by the
application program.