This section contains several topics you should take into consideration if you are using C++ to develop applications.
A Few Words on Typedefs
The OS/2 header files can be used with either C or C++ compilers. If __cplusplus has been defined, the header files will produce code that is compatible with C++. This is done since several of the typedefs have been changed to support C++. For example, many items that are unsigned char in the "C header files" are char when compiled with __cplusplus. For instance,
typedef unsigned char BYTE;has changed to
typedef char BYTE;
The existing samples that are included in the IBM Developer's Toolkit for OS/2 Warp Version 3 can be compiled with either C or C++.
Note: Prior versions of the IBM Developer's Toolkit for OS/2 Warp Version 3 provided two sets of header files: one set for use with C compilers, another set for use with C++ compilers. The same set of header files are now used by either compiler.
PCSZ Data Type
If a function takes as a parameter a string that is not changed by the function, the string parameter can be declared as a "const" string, or a PCSZ. PCSZ is defined in the header files as a "const" pointer to a NULL-delimited string.
The "const" means that the function will not change the contents of the string. The use of the "const" keyword is not specific to C++, many C compilers support it as well. However, the use of PCSZ allows for better optimization by the compiler and is more semantically compatible with C++.
The PCSZ data type is defined in addition to the PSZ data type. Existing code that calls functions that use PSZ will continue to work correctly, though they may cause warning or error messages when compiled.
LINK386
The C++ compiler will provide a dynamic link library which is be used by LINK386, or other OS/2 linker, when generating error messages. This DLL will convert a compiler generated mangled name into the function prototype. If the DLL is not present, an error message will be displayed and LINK386 will display the compiler-generated mangled name in error messages.