Directive #pragma Foundation

Activates or deactivates compiler switches during compile time

Syntax
#pragma <PragmaName>( <Option> )
Parameters
<PragmaName>
<PragmaName> must be an identifier from the following table:
Identifiers for pragmas
Pragma Description
Ansi2Oem Converts literal character strings to OEM
AutoMemvar Declares PRIVATE and PUBLIC variables as MEMVAR
DynamicMemvar Treats undeclared variables as MEMVAR
Info Toggles the display of all or particular warnings
Library Declares LIB files for the linker
LineNumber Toggles creation of line numbers
Map Maps function symbols to another symbol
Oem2Ansi Converts literal character strings to ANSI
Shortcut Toggles logical short-cut optimization
<Option>
Except for #pragma Info() and #pragma Library() either ON or OFF must be used for <Option>. ON activates the pragma (or compile switch) and OFF deactivates it.
Description

A pragma is a directive that changes a compile switch while the compiler translates source code. This allows compiler switches for a single line of code in a PRG file to be set or suspended.

Ansi2Oem

The pragma Ansi2Oem(ON|OFF) toggles the compiler switch /go which causes the compiler to convert literal character strings in the source code to the OEM character set.

AutoMemvar

AutoMemvar(ON|OFF) toggles the compiler switch /a, which declares all dynamic memory variables as MEMVAR (PRIVATE, PUBLIC or PARAMETERS).

DynamicMemvar

DynamicMemvar(ON|OFF) toggles the compiler switch /v, which treats all undeclared variables as MEMVAR.

Info

The pragma Info() enables or disables all or particular warnings of the compiler. Instead of the options ON|OFF, key word pairs are used to toggle particular warnings. They are listed in the following table:

Options for pragma Info()
Option Enables | disables warning...
ALL | NONE All warnings
DYN | NODYN Warnings that are displayed with the /w switch (usage of undeclared dynamic variables)
LEX | NOLEX Warnings that are displayed with the /wl switch (usage of non lexical variables)
INIT| NOINIT Warnings that are displayed with the /wi switch (variable is not initialized)
USE | NOUSE Warnings that are displayed with the /wu switch (unused lexical variables)
RESTORE Restores the last Info() setting

Library

Either the option NONE is indicated for the Library() pragma, or a comma-separated list of libraries (LIB files) must be specified. The file names of the libraries must be enclosed in quotes. Option NONE works like the compiler switch /nod (No default library). If file names are listed, this is equal to the compiler switch /r. Therefore, libraries can be defined for the linker in a PRG file.

LineNumber

LineNumber(ON|OFF) toggles creation of line numbers. The default is ON. Specifying OFF is equal to the compiler switch /l.

Map()

This #pragma is usually only required when function developed using the C-API are called in an Xbase++ program. It is used in the following way:

#pragma Map( <oldSymbol>, "<newSymbol>" ) 

This causes the compiler to replace the symbol <oldSymbol> of function/procedure calls and declarations with <newSymbol>, so that <oldSymbol> does not exist in the resulting OBJ file. Note that <newSymbol> must be enclosed in quotes.

Oem2Ansi

The pragma Oem2Ansi(ON|OFF) toggles the compiler switch /ga which causes the compiler to convert literal character strings in the source code to the ANSI character set.

Shortcut

Shortcut(ON|OFF) toggles the compiler switch /z, which activates or deactivates short-cut optimization of combined logical expressions.

Examples
Using pragmas

// Two identical IF conditions are programmed in the example, 
// and operations are performed with a declared and an 
// undeclared variable. The compiler displays no warning 
// for the second IF condition. The expression on the 
// right side of the .OR. operator is evaluated because 
// short-cut optimization is switched off. 

#pragma Info( DYN )   

PROCEDURE Main 
   LOCAL nNum1 := 0 

   nNum2 := 0                 // Warning! 

   IF ++nNum1 == 1 .OR. ++nNum1 == 2 
      ? nNum1                 // Result: 1 
   ENDIF 

#pragma DynamicMemvar( ON ) 
#pragma Shortcut( OFF ) 
#pragma Info( NODYN )         // No Warning 

   IF ++nNum2 == 1 .OR. ++nNum2 == 2 
      ? nNum2                 // Result: 2 
   ENDIF 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.