Build Subsystems (OS/2, Windows)

You can build a subsystem from ordinary C or C++ source files. No special file extension is required. A subsystem can be an executable program or a DLL.

You can use the following features of VisualAge C++ in a subsystem:

You cannot use any of the C++ classes in the IBM Open Class Library in a subsystem.

In addition, you may have to allow for the following special considerations of subsystems:

You follow the same process to build a subsystem as you do to create an ordinary executable program or a DLL, except that you must build with option link(standAlone) so that you link with the VisualAge C++ subsystem library.

Arguments of main in Subsystems that are Executable Programs
A subsystem supports the arguments to main usually called argv and argc. Therefore you can pass command line parameters to main. However, you cannot use the envp parameter in main.

Input and Output
You can perform limited input and output operations by using the low-level I/O functions in <io.h>. These functions are included in the subsystem library, but no other I/O functions are available. You are responsible for the buffering and formatting of I/O. Although the low-level I/O functions defined in <io.h> are reentrant, you should serialize access to these functions within each file. If you do not serialize the access, you may get unexpected input or output.

Calling Conventions for Functions Called in Subsystems
You must use one of the following calling conventions for your own functions in subsystems.

If your program calls external functions that are not compiled with VisualAge C++ you must use the following linkage convention:

You can specify the calling convention for individual functions with linkage keywords in your source, or you can set the default calling convention by building with gen(call, convention).

In C sources, you can also specify calling conventions with #pragma linkage.

_DLL_InitTerm Function for Subsystem DLLs
The _DLL_InitTerm function must has the same prototype but different content for subsystem DLLs than for regular DLLs. This function is the initialization and termination entry point for all DLLs. It initializes and terminates the environment for the DLL, including storage, semaphores, and variables. The version provided in the subsystem libraries defines the entry point for the DLL, but does not perform all the initialization or termination actions of the regular _DLL_InitTerm function. It does initialize the heap so you can use dynamic memory.

If your subsystem DLL requires any initialization or termination, you will need to create your own _DLL_InitTerm function. Otherwise, you can use the default version.



Subsystems
Signal and Exception Handlers in DLLs
Calling Conventions


Change a Build Setup
Set Build Options
Build
Build Dynamic Link Libraries
Build Executable Programs
Initialize and Terminate Your DLL Environment


Subsystem Library Functions
The _DLL_InitTerm Function on OS/2
The _DLL_InitTerm Function on Windows
Build Options