Next: Declaring OS-level libraries, Previous: Calling C function pointers, Up: C Interface
You can give a name to a bunch of C function declarations (a library interface), as follows:
c-library lseek-lib \c #define _FILE_OFFSET_BITS 64 ... end-c-library
The effect of giving such a name to the interface is that the
generated files will contain that name, and when you use the interface
a second time, it will use the existing files instead of generating
and compiling them again, saving you time. Note that even if you
change the declarations, the old (stale) files will be used, probably
leading to errors. So, during development of the declarations we
recommend not using c-library
.
Note that the library name is not allocated in the dictionary and
therefore does not shadow dictionary names. It is used in the file
system, so you have to use naming conventions appropriate for file
systems. Also, you must not call a function you declare after
c-library
before you perform end-c-library
.
A major benefit of these named library interfaces is that, once they are generated, the tools used to generated them (in particular, the C compiler and libtool) are no longer needed, so the interface can be used even on machines that do not have the tools installed.
c-library-name
c-addr u – gforth “c-library-name”
Start a C library interface with name c-addr u.
c-library
"name" – gforth “c-library”
Parsing version of c-library-name
end-c-library
– gforth “end-c-library”
Finish and (if necessary) build the latest C library interface.