SDL

Requirements
To port SDL applications to OS/2, you'll need the latest SDL binaries and header files from Netlabs. Currently the OpenWatcom compiler is the compiler for the OS/2 port of SDL, but it should also work with GCC.

Using the OpenWatcom compiler
There are some requirements and tricks with using the OpenWatcom compiler to port SDL applications. You should note the followings things.

Use the -ei switch for the OpenWatcom C compiler
You have to use the -ei switch for the OpenWatcom C compiler to have the size of enums equal to the size of ints. This is a requirement of SDL itself.

Wrapping the SDL_Quit function
The OS/2 version of SDL is compiled into a DLL file. This DLL file has all the SDL functions exported by name. In order to be able to use this DLL from the most compilers, these exports are using the _Syscall calling convention. This leads to problems with some SDL apps, where they assume that the calling convention of the API is the same as the calling convention of their runtime library. For example, the following line is very usual in SDL applications:

... exit(SDL_Quit); ...

This should be worked around by creating a wrapper function for SDL_Quit, and using that one, this way:

void SDL_Quit_Wrapper {   SDL_Quit; } ... exit(SDL_Quit_Wrapper); exit(SDL_Quit);
 * 1) ifdef __WATCOMC__
 * 1) endif
 * 1) ifdef __WATCOMC__
 * 1) else
 * 1) endif;

Using the GNU C Compiler
Hmm, needs somebody who has experiences with it. :)

Morph your program to a PM program at runtime
Most SDL applications assume that they can write to STDOUT, and the user will see it. In OS/2, you have to compile your application to a PM application in order to be able to have a PM Window, but the STDOUT will go to NULL in this case. The solution is to compile your code to a VIO application, and morph the application to a PM one dynamically, at runtime, before calling SDL_Init.