User`s manual

46 digi.com Language
4.21 Libraries
Dynamic C includes many libraries—files of useful functions in source code form. They are located in the
\LIB directory where Dynamic C was installed. The default library file extension is .LIB. Dynamic C
uses functions and data from library files and compiles them with an application program that is then
downloaded to a controller or saved to a .bin file.
An application program (the default file extension is .c) consists of a source code file that contains a main
function (called main) and usually other user-defined functions. Any additional source files are consid-
ered to be libraries (though they may have a .c extension) and are treated as such. The minimum applica-
tion program is one source file, containing only:
main(){}
Libraries (those defined by you and those defined by Rabbit) are “linked” with the application through the
#use directive. The #use directive identifies a file from which functions and data may be extracted.
Files identified by #use directives are nestable, as shown below. (The #use directive is a replacement
for the #include directive, which is not supported in Dynamic C.)
Figure 4.1 Nesting Files in Dynamic C
Most libraries needed by Dynamic C programs have #use statements in lib\..\default.h.
Section 4.23 explains how Dynamic C knows which functions and global variables in a library are avail-
able for use.
...
#use x.lib
...
main(){
...
}
...
#use z.lib
...
...
#use y.lib
...
function
...
function
...
function
...
#use z.lib
...
Application
X.LIB
...
......
...
.....
..
....
Y.LIB
...
......
...
.....
..
....
Z.LIB
BIOS