Skip to main content

Compiler Directives

Preprocessor statements issued to the MVBasic compiler.

Synopsis

Caché MVBasic supports most, but not all of the compiler directives provided by other flavors of MultiValue. The MultiValue Basic Quick Reference contains a Compiler Directives table showing which of the UniVerse compiler directives are supported by Caché MVBasic. The following are the Caché MVBasic compiler directives:

#INCLUDE

#INCLUDE program
#INCLUDE filename program
#INCLUDE filename,section program
#INCLUDE account,filename, program
#INCLUDE account,filename,section program

Inserts MVBasic source code from a specified shared library routine into the program being compiled. The inserted code is compiled along with the program in which it is included. The program shared library routine has a .h suffix. If filename is omitted, defaults to the filename of the current program. The account name (namespace name) and the section name are optional.

#PRAGMA

#PRAGMA ROUTINENAME=rrr

When you compile an MVBasic routine, the system generates a default routine name, with the format MVB.xxx. This name applies to the intermediate MVI source code (xxx.mvi) and to the object code (xxx.obj).

Use #PRAGMA to override this default and specify this routine name. You do this by adding the following statement to the source code file: #PRAGMA ROUTINENAME=rrr, where “rrr” is the routine name. This routine name must satisfy the naming convention syntax for Cache routines: the first character must be % or a letter, and subsequent characters must be letter, a number, or a period.

Caution:

Use care in selecting a routine name, or when copying program code that contains #PRAGMA ROUTINENAME=rrr. #PRAGMA creates a routine with the specified name even if that name was already assigned to an existing routine. It overwrites the object code for an existing routine with object code for the current routine.

Once a routine name has been associated with a source file, that name will continue to be used, even if the #PRAGMA statement is removed. To stop using this associated routine name and have the system generate a new default routine name, specify an empty routine name:#PRAGMA ROUTINENAME="".

This empty routine name should be specified only for the first compile. This removes the associated routine name. The #PRAGMA statement should then be removed before subsequent compiles of the source code file. Otherwise the system will continue to generate a new name each time the routine is compiled, instead of each compile replacing the prior existing routine.

$COPYRIGHT

$COPYRIGHT text

The $COPYRIGHT statement inserts the specified copyright text into the generated object code. This text is a non-executable comment. text is a string enclosed in double or single quotes. The text string can include Unicode characters.

If there is more than one $COPYRIGHT statement in a routine, only the text from the final $COPYRIGHT is inserted into the generated object code.

$DEFINE

$DEFINE symbol value

Assigns a value to a symbol used at compile time.

Do not specify a comment on the same line as a $DEFINE statement. $DEFINE uses the entire line as is, including any leading or trailing blank spaces and any comments.

The preprocessor symbol INTERSYSTEMS is automatically defined for all Caché MVBasic compilations.

$IFDEF / $IFNDEF

Performs a logical branch based on whether a symbol is defined ($IFDEF) or not defined ($IFNDEF). Specify a block of dependent code after this statement. You can use or omit a $ELSE clause. Terminate the block of dependent code with a $ENDIF keyword.

The preprocessor symbol INTERSYSTEMS is automatically defined for all Caché MVBasic compilations.

$INCLUDE

A synonym for #INCLUDE.

$INSERT

A synonym for #INCLUDE.

$UNDEFINE

Removes an assigned meaning from a symbol used at compile time. $UNDEFINE reverses the action of $DEFINE.

FeedbackOpens in a new tab