Show/Hide Toolbars

XSharp

The -vo8 option enables Visual-Objects compatible preprocessor behavior.

Syntax

-vo8[+|-]

Arguments

+ | - Specifying +, or just -vo8, changes certain aspects of the preprocessor to behave like Visual Objects.

Remarks

Unlike Visual Objects, X# uses a file-based preprocessor which has characteristics of traditional preprocessors in languages such as C, C++ and Clipper. The -vo8 option controls the following behaviors:

 

Case Sensitivity

In a traditional preprocessor, #define foo 1 and #define FOO 2 declare two separate preprocessor symbols, because preprocessor symbols are case-sensitive.

 

However, in Visual Objects, DEFINE foo := 1 and DEFINE FOO := 2 declare the same entity (and would cause a compiler error because of the duplicate entity declaration).

 

In X#, by default, that is when -vo8 is disabled (not used or specified with "-vo8-"), preprocessor symbols are always case sensitive. When -vo8 is enabled, then the case sensitivity of symbols is decided by the state of the -cs option:

- when -cs is enabled, which makes the compiler treat all identifiers and type names as case-sensitive, then also preprocessor symbols are still case-sensitive

- when -cs is disabled, then preprocessor symbols are case-insensitive and behave in the same way as in VO

 

So, when -vo8 is enabled and -cs is disabled, #define foo 1 and #define FOO 2 declare the same preprocessor symbol (and would cause a compiler warning because of the redefinition).

 

The following code is valid in Visual Objects:

 

DEFINE foo := "bar"
? Foo // "bar"

 

but the following code would raise an unknown variable error on ? Foo because the X# preprocessor is case-sensitive by default:

 

#define foo "bar"
? Foo

 

 

Using The -vo8 (but not the -cs) option will allow the above example to compile. An alternative to using -vo8 is to modify the code so that the case of the text you want to replace matches the case used in #define.

 

#ifdef

 

In a traditional preprocessor, code within a #ifdef ... #endif (or #else) block is compiled if the symbol after #ifdef is defined. It does not matter what the symbol resolves to, if it resolves to anything at all.

 

In Visual Objects, code within a #ifdef ... #endif (or #else) block is compiled only if the symbol after #ifdef is defined, and it resolves to an expression which resolves to a logical TRUE value. In the example below, The code will print "in #else":

 

DEFINE foo := FALSE
 
#ifdef foo
? "in #ifdef
#else
? "in #else" // <- this code is compiled in Visual Objects
#endif

 

whereas the equivalent code in X# would print "in #ifdef":

DEFINE foo := FALSE
 
#ifdef foo
? "in #ifdef // <- this code is compiled in Vulcan.NET
#else
? "in #else"
#endif

 

 

When -vo8 is used, the X# preprocessor examines the value of the preprocessor symbol to determine if the symbol resolves to a logical TRUE or FALSE value.  However, the X# preprocessor does not evaluate preprocessor expressions, whereas Visual Objects does. Even with -vo8 enabled, the preprocessor symbol must resolve to a single expression containing TRUE or FALSE (case-insensitive) or a numerical value.

Numerical values of 0 resolve to FALSE and all non-zero numbers resolve to TRUE. Preprocessor symbols that resolve to expressions are not evaluated and effectively resolve to FALSE.

To set this compiler option in the Visual Studio development environment:

 

1.Open the project's Properties page.

2.Click the Dialect tab.

3.Change the value.

4.Click here to see the property page

Example

// For the purposes of #ifdef...
 
// these resolve to FALSE:
#define foo FALSE
#define foo 0
 
// these resolve to TRUE:
#define foo True
#define foo 1
#define foo -567
 
// these are not processed and effectively resolve to FALSE
// and therefore are incompatible with Visual Objects:
#define foo TRUE .AND. TRUE
#define foo TRUE .OR. TRUE
#define foo 1 * 2

 

Tip:

The -ppo option is useful for debugging the output generated by the preprocessor.