User Tools

Site Tools


define_pragmas.htm
Navigation:  Advanced Topics > Legacy Project System Reference >====== Define #pragmas ====== Previous pageReturn to chapter overviewNext page

A #pragma whose class name is define is used to define a conditional compile symbol for subsequent compiles. The symbol is available for interrogation by the OMIT and COMPILE compiler directives. See the Language Reference for more information. This #pragma may only be used in project files.

A define #pragma takes the form:

#pragma define(ident⇒value)

where ident names the symbol and value specifies the value it is given.

For Modula-2, the given identifier is defined as a boolean constant with value TRUE if the value on was specified, otherwise FALSE. For C and C++, the given identifier is defined as a macro. If the value on is specified, the macro is defined to the value 1. If the value off is specified, the macro is not defined. Any other value will cause the identifier to be defined as a macro expanding to the given value. Only a single C or C++ token may be specified, or the compiler will report an error. To define a macro where the value is a string literal, use a command of the form #pragma define (name ⇒ '“fred”').

The following define #pragmas are available:

#pragma define(asserts ⇒ 0 | 1 )

#pragma define(bcd_arithmetic ⇒ on | off )

#pragma define(bcd_large ⇒ on | off )

#pragma define(bcd_ulong ⇒ on | off )

#pragma define(big_code ⇒ n)

#pragma define(compatible_modulus⇒ on | off )

#pragma define(dll_mode ⇒ 0 | 1 )

#pragma define(init_priority ⇒ n)

#pragma define(local_implicits ⇒ 0 | 1 )

#pragma define(logical_round ⇒ on | off )

#pragma define(maincode ⇒ on | off )

#pragma define(profile ⇒ on | off )

#pragma define(safe_heap ⇒ 0 | 1 )

#pragma define(stack_threshold ⇒ size )

#pragma define(wdnu ⇒ off | on)

#pragma define(wpnu ⇒ off | on)

#pragma define(zero_divide ⇒ on | off )

NoteBox.jpg

A pragma can be used in the Project language, C++ code, Modula-2 code, or Clarion code. Some only work in certain places. A 'P' to the right of the pragma indicates it can be used in the Project language, a 'C' indicates it can be used in C++ code, a 'M' indicates it can be used in Modula-2 code, and a 'W' indicates that it can be used in Clarion code (CLW files).

#pragma define(asserts ⇒ 0 | 1 ) pw

If the value is 0, and the debug information is not active (generating), the compiler generates nothing for any ASSERT statement detected. If the value is 1, or the debug information is being generated, the compiler produces the code to show the assert dialog. This code can be replaced by setting SYSTEM{PROP:AssertHook} property. If the pragma is set to 1, the call to show the assert dialog is generated regardless of the value of the debug(vid) pragma.

#pragma define(bcd_arithmetic ⇒ on | off ) pw

Specifies use of Binary Coded Decimal (BCD) arithmetic when on (default) and forces use of Floating Point arithmetic when off.

#pragma define(bcd_copies ⇒ 0 | 1 ) pw

If pragma is set to 1 (default value), the compiler is trying to keep expression type as DECIMAL if all arguments are integers or DECIMALs or PDECIMALs as long as possible. Otherwise, arguments are converted to REALs.

#pragma define(bcd_large ⇒ on | off ) pw

Enables or disables use of DECIMAL and PDECIMAL variables greater than fifteen (15) digits. The default is on (enabled).

#pragma define(bcd_ulong ⇒ on | off ) pw

Specifies use of Binary Coded Decimal (BCD) arithmetic for ULONG variables when on (default) and forces use of Floating Point when off. This define is overridden with define(bcd_arithmetic⇒off)

#pragma define(big_code ⇒ n) p

Specifies number of procedures per segment. By default (n = 0) all procedures ina single module go into a single code segment. Setting the value of n for a specific module “breaks up” the module containing a large number of procedures which “breaks” the 64K code segment limit.

#pragma define(compatible_modulus⇒ on | off ) p

Controls the sign of the result of modulus division. If the pragma is set to zero (OFF), the modulus result uses the sign of the divisor. If the pragma is set to one (ON), the modulus result uses the sign of the dividend.The default is off.

Example:

If compatible_modulus = 0, then

42 % -5 = -2 (-5 is the divisor(-) )

If compatible_modulus = 1, then

42 % -5 = 2 (42 is dividend (+))

#pragma define(dll_mode ⇒ 0 | 1 ) pw

The project system sets this pragma to 0 if the link mode is set to Local in the project, and sets it to 1 otherwise. The program should not override the project settings.

#pragma define(init_priority ⇒ n) pw

Specifies a number (n) that is compatible with the C++module priority schema. Default is 5.

#pragma define(local_implicits ⇒ 0 | 1 ) pw

If the pragma is set to 0 (default value), implicit variables that are declared in the procedure are accessible from ROUTINEs and methods of local classes. If pragma is set to 1, implicit variables with the same name are allocating separately in each scope.

#pragma define(logical_round ⇒ on | off ) pw

Specifies rounding behavior when truncating a REAL to a LONG. When on, the result is rounded up if the REAL value is “close to” the next larger integer. When off (default), no rounding occurs.

#pragma define(maincode ⇒ on | off ) pw

Enables (on'the default) or disables (off) generation of initialization code. Turn maincode off when compiling generic modules or LIB modules.

#pragma define(profile ⇒ on | off ) pw

Specifies the compiler will invoke a procedure call at the beginning and end of compiling each procedure. This allows you to implement your own profiler. The prototypes for these procedures must be:

EnterProc(UNSIGNED Line,*CSTRING Proc,*CSTRING File),NAME('Profile:EnterProc')

LeaveProc(),NAME('Profile:LeaveProc')

The EnterProc is called at the beginning of each procedure and LeaveProc at the end.

#pragma define(safe_heap ⇒ 0 | 1 ) pw

If the pragma is set to 1 (default value), the compiler generates the code to set a pointer to NULL after it has been freed. Otherwise, the value of the pointer remains the same as it was before the call to free().

#pragma define(stack_threshold ⇒ size ) pw

Specifies the size (in bytes) of the threshold at which any data structure larger than the specified size (default is 16384) is assigned heap memory instead of stack memory.

#pragma define(wpnu ⇒ on | off ) pw

Parameter never used in function. When on, the compiler checks for a parameter that the code never uses, so declaration of dummy parameters generates warnings. The default setting is off.

#pragma define(wdnu ⇒ on | off ) pw

Variable declared but never used. When on, the compiler checks whether a local variable has been declared but never used in the function. The default setting is off.

#pragma define(zero_divide ⇒ on | off ) pw

Specifies divide by zero behavior. When on, division by zero returns zero. When off (the default), division by zero returns an exception.

define_pragmas.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1