12.4 Object output file OBJ
----------------------------
Currently C-- can create OBJ files but cannot link them.
Earlier versions of C-- could create OBJ files which you could then use
in projects created in other languages, or 'slave' modules. But only
functions were available of C-- modules for the basic project, and these
functions could not use global variables.
But now C-- can create a 'master' module which can be linked to an
independent file.
It is now possible to use as an OBJ file external (extern) functions,
variables or structures. You need only declare them as extern. The keyword
'extern' must always be the first Here is an example of how to declare
external objects.
extern void cdecl _printf(); // declaration of external function _printf of
// type cdecl and return type void
extern int buts,cubs; // declaration of two external variables of type int
extern struct IPXL ipxl; // declaration of ipxl external structure with IPXL
// tag, which tag must have been described
// previously.
Now that you can declare external objects, you can link to a C-- OBJ
module modules written in other languages, or you can attach to a C--
program functions from libraries in other languages. When declaring
external objects it is very important to correctly specify the type and
name of the function. When using external functions written in C, you will
usually need to specify the cdecl modifier and add '-' to the name of the
function or variable.
All functions, global variables and global structures from the master
OBJ file written in C-- are available for other modules.
To obtain a slave OBJ module during compilation use the switch /sobj.
C-- can create OBJ files with tiny or small memory model, with tiny
being the default. To obtain a file with the small memory model start the
compiler using the switches /obj and /exe.
To create OBJ files for 32-bit DOS use the command-line switches /d32
and /obj. I was able to use the resulting OBJ files only with wlink and
the DOS extender zrdx.exe.
C-- provides no method of creating OBJ files for Windows.