Arity/Prolog32 compiler options

The Arity/Prolog32 compiler generates a standard object module from a Prolog source file. The resulting object module is linked with the Arity/Prolog32 object modules and any other application object modules to form a stand-alone application or is linked to create a dynamic linked library (DLL). Before attempting to compile an application, make sure you have added all the necessary code declarations.

The compile command is issued from the operating system prompt. It has the following general format:

apc32  [options] <source>

The source argument gives the name of the Prolog source file to be compiled. The Arity/Prolog32 compiler assumes that all source files end with the .ari extension if no extension is given. The compiler assumes the name of the object module to be generated and the database file from the base name of the source module. These files may be specified by using compiler options. Other switches and options allow you to do the following:

• Specify file names • Specify module specific compilation • Define a macro • Perform a syntax check • Ignore mode declarations • Specify a directory to include files from • Quiet the compiler output

You may combine any of the compiler options described below. For instance, to compile the source file lists.ari withe the database file app.idb, generating the object module prolist.obj while ignoring mode declarations and including files from the directory c:\myapp\inc you would use the following command line:

>apc32 -m -I\myapp\inc -Foprolist.obj -Fdapi.idb lists.ari

Specifying files

The object module created and the database file used to compile a source code file are assumed to have the same root name as the source file with the .obj and .idb extensions. The -Fo compiler option can be used to specify a different file name.

-Fo<name>

The name specified will be used for the object file that is created. If no extension is given, then .obj is assumed. There are no spaces between the "o" and the given name.

Note: When adding an evaluable predicate to the interpreter, the database name is api. When creating a stand-alone program, the name must be the same as the module name of the file containing the main/0 predicate.

Specify module names

The name associated with a module as well as the name of segments containing Prolog code, C code and C data within the module can be specified using the -N options. There are four forms of this option supported:

-Nm<name>

The name specified is used as the name of the module. This name may also be specified with the module declaration.

-Ns<name>

The name specified is used as the segment name for the Prolog code generated in the module. You must create a segment header for this segment with the clone utility and link the header as part of your application. This name may also be specified with the segment declaration.

-Nc<name>

The name specified is used as the segment name for C code generated in the module. This name may also be specified with the cseg declaration.

-Nd<name>

The name specified is used as the segment name for C data generated in the module. This name may also be specified with the dseg declaration.

Note: If one of the corresponding declarations is contained in the file, it will override the compiler option.

Specifying model specific information

Info

The discussion here is incorrect and needs revision. Arity/Prolog32 supports only the model where segment registers all use the same operating system provided value.

The -M family of options lets you specify on the compiler command the model and specifier as you would with the model declaration. These specifiers used by the embedded C compiler, which is described in detail in chapter nnn. Seven options are supported:

  • -Ms small model
  • -Ml large model
  • -Mm medium model
  • -Mc compact model
  • -Md specifies DS=SS
  • -Mv specifies DS \=SS, DS reloaded on function entry
  • -Mw specifies DS \=SS, DS reloaded on function entry

Model and function specifiers can be combined, such as -Mlu or -Mmw. A model declaration within the file will overide the settings on the command line.

Specifying predicate interaction

The compiler supports a family of options for making predicates visible, public or specifying how undefined predicates are treated. Any public, visible or extrn declarations within the file will take precedence over the compiler command line switches. The -P switches supported are:

-Pv

all predicates in the file will be declared visible.

Pp

all public predicates in the file will be declared visible.

-Pb

all of the Arity/Prolog32 builtin predicates will be declared visible.

-Pg

all predicates in the file will be made global (public with the far suffix).

-Pf

all undefined predicates will be declared extrn with the far suffix.

-Pn

all undefined predicates in the file will be considered to be near extrns.

Several options may be specified together. For instance, making all Arity/Prolog32 builtins visible, all public predicates visible and all undefined predicates be near extrns you would specify

-Pbpn

Defining macros

You can define one or more macros on the compiler command line using the -D option. You specify a string that is passed directly to the define declaration code. If you have any spaces in your string, then you need to enclose the string with double-quotes. Some examples of defining macros are:

-Dsys=win32
-D"end_time is start_time + 20"
-D"min(X,Y,Z) = ifthenelse(X<Y, Z=X, Z=Y)"

Structure packing

The compiler supports structure packing for C structures declared within a module. You can specify that structure packing should take place with the pack declaration or by using the -k switch on the compiler command line.

Performing a syntax check

The -c switch can be used to cause the compiler to only perform a syntax check of the source file. Use this switch at the beginning of your compile statement:

apc32  -c <source>

Ignoring mode declarations

If you want the compiler to ignore mode declarations contained in your source code, specify the -m option in your compile statement.

Specifying a directory to include files from

You may use the -I option to add a directory to the list of directories/paths searched for include files. Initially, only the INCLUDE environment variable and the directory of the source file is searched. You may specify additional directories with additional -I options. The compiler searches for include files in the following order:

  1. The current directory
  2. The -I option specified directories
  3. The INCLUDE environment variable

Quieting the compiler output

As the compiler processes a file, it will write the name of each predicate it compiles. If you wish to quiet this output, then simply add the -q switch to your compile line. For example:

apc32  -q append.ari

Specifying arithmetic processing

By default all arithmetic in a Prolog program is interpreted by the is/2 predicate so that any variables contained within the expression could be unified with an expression. However, if all of the varaibles were guaranteed to be bound to numeric values when the call is made, you could spcify that the expression is compiled rathered than interpreted. In order to do so, you must specify a data type that all of the inputs will be cast to. This data type can be either short integers, long integers or doubles (floating-point numbers). The method to use for handling the is/2 predicate can be specified with the arith directive (see page 382) or the -H family of compiler switches:

-Hi

Arithmetic is handled by the is/2 predicate (interpreted).

-Hs

Arithmetic is compiled, inputs are cast to shorts.

-Hl

Arithmetic is compiled, inputs are cast to longs.

-Hd

Arithmetic is compiled, inputs are cast to doubles.

The -link option is used to specify that upon successful compilation of your source, the compiler will attempt to link your application by calling the LINK.EXE program. You may specify in a string a number of parameters that will be passed to the linker or none at all. For instance, the following are valid:

apc32 myapp -link
apc32 myapp -link"/MAP /NOE /NON"