Compiler options and directives for Windows

In this section:

This section describes the compiler options and directives that are provided for the purpose of creating Windows executable programs. Information about other compiler options and directives will be found in the user guide for your Silverfrost compiler.

Using ClearWin+, a Windows application can be created in one of two ways. One approach is to compile the main program using the /WINDOWS command line option and then run the linker separately (other routines that have not been compiled with /WINDOWS may also be linked in). Further details of this approach are given below. The other method is to use one of the compiler command line options /LINK and /LGO and to insert the WINAPPcompiler directive into the program code before the main program.

The WINAPP directive takes the form:

WINAPP resource_file

The /WINDOWS command line option becomes redundant when this directive is used. When used, WINAPP should be the first compiler directive in the file and must appear before the main program. WINAPP can take either no arguments or one argument. If the resource script file is specified, the SRC resource compiler is invoked (see Using the Silverfrost Resource Compiler) to compile the resource script. If it is not specified, the application will simply be marked as a Windows application rather than a Console application.

For Win32 applications, the resource file name must have a different stem (i.e. the part before the extension) from all the other source file names. For example, do not use prog.rc with prog.for. If you did not obey this rule, both files would be compiled into prog.obj and one would overwrite the other.

Resources are automatically appended to the executable or DLL being created. However, by default ClearWin+ only searches for resources in the current executable. Calling the subroutine USE_RESOURCE_LIBRARY@ causes ClearWin+ to also search in a given DLL. The call takes the form:


where mylib.dll is the name of the DLL.

Fortran 77 routines that use ClearWin+ and/or the Windows API should include the line

INCLUDE <windows.ins>

unless the routine only refers to winio@ or RGB@ (say) which can be declared as INTEGER in the routine. Note the use of "<" and ">" to denote that the default directory for system include files should be searched. The file called windows.ins references three other files as follows:

INCLUDE <clearwin.ins>
INCLUDE <win32api.ins>
INCLUDE <win32prm.ins>

These files are installed into the INCLUDE sub-directory of your chosen installation directory (the default installation directory is c:\win32app\salford). Where appropriate, clearwin.ins can be used in place of windows.ins in your program. This will reduce the amount of processing at compile time.

Fortran 90/95 routines can alternatively make use of the file mswin.mod instead of windows.ins via the statement


The source file for mswin.mod references three other files as follows:

MODULE mswin
  USE msw32prm
  USE mswin32
  USE clrwin

Where appropriate, clrwin can be used in place of mswin in your program. This will reduce the amount of processing at compile time.

It is recommended that you use the IMPLICIT NONE statement at the start of any routine that uses the windows.ins file. Without IMPLICIT NONE, a mispelt Windows parameter (some are very long) will not be detected at compile time. Such bugs are very hard to find in the Windows environment.


Of necessity, the three include files and the equivalent module files contain many thousands of lines of declarations in order to provide you with full access to all the ClearWin+ functions and the Windows API. Once you are familiar with the concepts described in this guide, you may find it helpful to create your own include or module file that contains only those declarations that are used by your programs. If you use IMPLICIT NONE, and remove references to windows.ins or msmod, the compiler will report all usage of undeclared variables and functions. You can then search the relevant include or module files for the missing names and, using a text editor, build up your own include or module file. Note that ClearWin+ routines (whose names usually end in an "@" character) will appear in a C_EXTERNAL statement in order to provide the compiler with a reference to a routine in the run time library. If you take the time to make your own include or module file, the benefits of much faster compilation will be immediately obvious, especially if your program contains many sub-programs that use these include or module files.

Unlike a Console application, a Windows application does not create or inherit a console (i.e. a DOS box), and any default input/output is directed to a ClearWin window (which can be embedded inside other windows using %cw (ClearWin Window)). Although a simple ClearWin+ window can be displayed from a Console application, the rules concerning which Windows API calls will work from within a Console application are ill-defined (ClearWin+ calls all ultimately resolve into API calls). Therefore, it is recommended that all ClearWin+ applications should be set up as Windows applications using the WINAPP directive.



Copyright © 1999-2023 Silverfrost Limited