#COMPILE metastatement

Purpose

Determine what type of file will be created by the compiler.

Syntax

#COMPILE {EXE | DLL} ["filename{.exe|.dll}"]

Remarks

This metastatement is used to specify whether a module is to be compiled as an EXE or as a DLL file. The #COMPILE metastatement can only be used once per program, and must be placed before any executable code.

You may, optionally, specify the target name and directory of the file. If this clause is omitted, the compiled file is given the name of the main source code file with an .EXE or .DLL extension.

Some examples follow:

#COMPILE EXE ' Same name as source, i.e., ABC.EXE

#COMPILE DLL ' Same name as source, i.e., ABC.DLL

#COMPILE EXE "ABC" ' Compiles to ABC.EXE

#COMPILE DLL "ABC" ' Compiles to ABC.DLL

#COMPILE EXE "ABC.BAS" ' Compiles to ABC.EXE

If a path is included, the compiled file is placed in the named directory; otherwise, it is placed in the current directory.

If the named directory does not exist, the filename is invalid or locked, if the EXE is still running, or if the file cannot be successfully stored in that location for some other reason, a compile-time Error 496 ("Destination file write error") occurs.

Restrictions

If #COMPILE is not specified, the default is #COMPILE EXE. The default value has changed since early versions of PowerBASIC for Windows, so use an explicit #COMPILE metastatement to avoid ambiguity.

When compiling a DLL, the module may not include a PBMAIN or WINMAIN function. See DLLMAIN, LIBMAIN, and PBLIBMAIN for further information.

PowerBASIC metastatements support Long File Names (LFNs).

See also

#COMPILER, DLLMAIN, LIBMAIN, PBLIBMAIN, PBMAIN, WINMAIN