Calling C functions from Modula-3 (Win32)

In this example, we create an interface for accessing the MessageBox function from the Win32 API. To do so, we import the interface WinUser which defines the signature of the MessageBoxA call. We then call WinUser.MessageBox from the main module, OK.

This example only works on Win32, since MessageBox is a Win32 call, however, you can do similar things on other platforms, hence the program is not portable. Of course, if you were to only use the portable interfaces available in Modula-3, you would not have any portability problems.

The good news is that most of the time, we can program in the safe mode, so that the language takes care of things like garbage collection.