Compiler switches Foundation
The compilation of ASCII program code (either a PRG file or a PPO file) into binary program code can be controlled in specific ways using compiler switches. These switches must be specified along with the file name of the source code file when XPP.EXE is called. The following switches (<Options>) are valid for the compiler:
/?
Display information about all compiler switches. The /? switch only provides information and cannot be combined with other switches.
/a
Automatic MEMVAR declaration
When this switch is used, all variables specified with PRIVATE, PUBLIC or PARAMETERS are explicitly declared as MEMVAR.
/b
Insert debug information
When /b is used, debug information is written into the resulting OBJ file. This includes row numbers, names of lexical variables, the source code file name and other information.
If the /b switch is not included, the debugger cannot display information about the program source code at runtime of the resulting Xbase++ program. The debug information increases the size of both the OBJ file and the executable EXE file. For this reason, the final version of a program should be compiled and linked without /b.
/coff
Creates object files in Common Object File Format (COFF)
The Xbase++ compiler creates COFF object files if the switch /coff is set. On Windows platforms, this switch is activated by default. To create OMF object files, the /omf switch must be used.
/com
Use compatibility mode
In the compatibility mode, all identifiers (names) for functions, procedures, methods and variables are considered significant by the compiler only up to a maximum of 10 characters. The /com switch activates this mode. It should only be set when compiling Clipper programs with function names that are actually longer than 10 characters but abbreviated using only the first 10 characters. The side effect of the /com switch is that all Xbase++ functions with identifiers more than 10 characters long can no longer be called.
/d<id>[=<val>]
#define <id>
The /d switch specifies the #define constant <id> to the compiler on the command line. The #define constant is valid within the source code file. Optionally, the constant can be assigned the value <val>. If the value is to be a string literal (eg. #if LANG == "GER"), it must be enclosed in single or double quotation marks. Single quotation marks are recommended however, because command shell-specific escape rules must be considered for double quotation marks.
/dll[:DYNAMIC]
Create OBJ file for a DLL file
The /dll switch directs the compiler to include additional information necessary for the creation of a DLL file in the OBJ file. All OBJ files which are to be linked into a DLL file must be compiled using /dll. If the linker will create an EXE file, the switch must not be used.
/err:<count>
Terminate compiling after <count> errors
By default, the compiler terminates the compile process as soon as it registers 20 program errors. This value can be changed using the /err: switch. <count> specifies the maximum error count before compiler termination.
In some cases the number of 20 errors is reached very quickly. When the compiler detects a syntax error it tries to find the next entry point in the source code to continue the compile process with the remaining code. If no entry point is found after an initial error the compiler reports additional syntax errors even if the code is correct.
/es
Creates a operating system error code for warnings
When the switch /es is set the compiler creates an OS error code already for warnings and not when a syntax error is detected.
/ga
Converts literal strings from ANSI to OEM
When the /ga switch is set, all literal character strings in the PRG source code are converted from ANSI to OEM before the compiler creates the OBJ file.
/go
Converts literal strings from OEM to ANSI
When the /go switch is set, all literal character strings in the PRG source code are converted from OEM to ANSI before the compiler creates the OBJ file.
/i<path>
Search directory for #include files
The /i switch specifies an additional search directory <path>for the compiler to use when locating #include files. Normally, the compiler only searches for these files in the current directory and those directories specified by the INCLUDE environment variable.
/l
Insert no line numbers
If the /l switch is used, no line numbers are included in the OBJ file. This decreases the size of the executable EXE file, but has the disadvantage that it disables ability of the function ProcLine() to return line numbers. If /l is used and a runtime error occurs, it will not be possible to determine which line in the source code caused the error.
/link[:"options"]
Creates an EXE from the object file
The /link switch causes the compiler to start the linker when the OBJ file is successfully created. In this way it is possible to create an EXE file from a single PRG file by invoking the compiler only. Options for the linker can be specified with the /link switch as well. They must be enclosed in double quotes and are then passed on to the linker.
/m
Ignore SET PROCEDURE TO (ProcRequest)
The /m switch prevents automatic insertion of additional source code files (PRG files) which are specified using the command SET PROCEDURE TO. Since SET PROCEDURE TO is purely a compatibility command, the /m switch does not generally need to be used.
/n
No implicit start procedure (MAIN)
If program code is found in a source code file outside a FUNCTION, PROCEDURE or METHOD declaration, this program code is implicitly condensed in the procedure MAIN(). This default behavior can be suppressed by the /n switch. The compiler then creates error messages if it finds program code outside of a FUNCTION, PROCEDURE or METHOD declaration.
/nod
No default library in OBJ file
If the /nod (no default library) switch is used, the name of the file XPPRT1.LIB is not implicitly included in the OBJ file. The linker then only uses the LIB files specified with the /r switch.
/o<name>
Rename OBJ file
Normally, the compiler creates an OBJ file which has the same file name as the PRG file it is created from. The /o switch is used to rename the resulting OBJ file to <name>. If a different path is used in <name>, specifying the path name is sufficient. The name of the path must be terminated using a backslash \. The OBJ file is then created in the specified path with the same file name as the PRG file.
/omf
Creates object files in Object Module Format (OMF)
The Xbase++ compiler creates OMF object files if the switch /omf is set. On the OS/2 platform, this switch is activated by default. To create COFF object files, the /coff switch must be used.
/p
Create preprocessor output (PPO file)
If the /p switch is included, the compiler creates a PPO file containing the preprocessor output in addition to creating the OBJ file. The file has the same name as the source code file, but has PPO instead of PRG as the file extension. A PPO file can be used to determine whether user defined commands are correctly translated by the preprocessor.
/pptrace
Trace preprocessor's work
The /pptrace commands the preprocessor to print information about the applied translations (#[x]command/#[x]trans). This can help to find errors in these directives during development.
/profile
This option will generate profiling information used by the Xbase++ profiler. You need the Xbase++ profiler installed to successfully link and run the program.
/q
No screen display during the compiling (quiet)
The /q switch suppresses the display of line numbers during compilation. This allows the compiler to work faster.
/r<libname>
Specify LIB file for linker
The /r switch is used to specify an additional library <libname> for the linker to search in order to resolve external references when linking the OBJ file. By default, the linker searches the file XPPRT1.LIB and it does not need to be explicitly specified unless the /nod switch is used.
/s
Only test syntax
If the /s switch is used, the compiler merely performs a syntax check of the source code file and does not create an OBJ file.
/u[<name>]
Use user-defined STD.CH
The /u switch defines the #include file <name> as a replacement for the file STD.CH which is included by default in all source code files during compilation. A programmer who only uses commands to a very limited extent can copy these commands from the file STD.CH to another file and specify this file as the default using /u. This saves time when the preprocessor reads the #include file. If <name> is not specified, no default #include file is used.
/v
Treat undeclared variables as MEMVAR
By default the compiler treats undeclared variables which are not preceded by alias names as field variables. The /v switch causes the compiler to treat these undeclared variables as dynamic memory variables. These variables then receive the alias name MEMVAR->.
/w
Display warnings
The /w switch causes the compiler to output warnings on the screen when it detects undeclared variables which are not preceded by alias names.
/wi
Display warnings for non-initialized variables
The /wi switch produces warnings for all variables which are not initialized and appear in expressions where the variables must have a value.
/wl
Display warnings for non-lexical variables
The /wl switch produces warnings for all variables which are not declared as LOCAL or STATIC or included in the formal parameter list of functions, procedures and methods.
/wn
Display warnings for suspicious implicitly declared NILs
An implicitly declared NIL literal is created by the compiler if either a literal array or a parameter list has an empty element, such as {1,}. Sometimes such a NIL-literal is unintentionally created and may cause undesired effects or runtime errors.
/wn
Display warnings for suspicious implicitly declared NILs
/wu
Display warnings for unused lexical variables
The /wu switch produces warnings for all lexical variables which are declared and not used.
/z
Turn off logical short-cut optimization
The /z switch turns off the default "short-cut" optimization for the logical operators .AND. and .OR.. Without optimization, all expressions which are combined using logical operators are evaluated. With optimization, combined expressions are evaluated only until the result of the overall expression is clearly determined.
The compiler switches can be globally set by using the environment variable XPPCMDLINE. This can be useful if you need to temporarily turn on a switch or pass a define without changing the project file or the makefile.
This will turn on the options /w /wi /wu and /b for all subsequent calls to Xpp.exe using this environment.
!BExamples for the Xbase++ compiler
The following example performs a syntax check for the file MAIN.PRG and writes the preprocessor output into the file MAIN.PPO without displaying line numbers.
The next example creates the file TEST.OBJ including debug information. The OBJ file is written to the path \XPP\OBJ\. No implicit MAIN() procedure is created and warnings are displayed on the screen during compilation:
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.