Show/Hide Toolbars

XSharp

The -vo5 option directs the compiler to implicitly use the CLIPPER calling convention for functions declared with zero-arguments and no explicit calling convention.

Syntax

-vo5[+|-]

Arguments

+ | - Specifying +, or just -vo5, directs the compiler to implicitly use the CLIPPER calling convention for functions, methods and constructors that are declared with zero arguments and no explicit calling convention.

Remarks

For compatibility with Clipper, Visual Objects uses the CLIPPER calling convention for all functions and methods that are declared with zero arguments and no explicit calling convention. The STRICT keyword may be used to override the default, and cause the function to use the STRICT calling convention.

 

However, in the vast majority of cases, parameters are never passed to functions and methods declared with zero arguments, and using the CLIPPER calling convention by default incurs unnecessary overhead not only in the function itself, but at every call site. In addition, the CLIPPER calling convention allows any number and type of arguments to be passed, preventing compile time error checking.

 

In X#, functions and methods declared with zero arguments are compiled with the STRICT calling convention by default, unless the CLIPPER keyword is explicitly specified. This behavior is the exact opposite of Visual Objects, but results in more efficient code as well as compile time error checking. Passing any arguments to a function declared to accept zero arguments will raise a compile-time error.

 

However, this can cause compatibility issues in code originally written in Visual Objects. The -vo5 compiler option reverses the default behavior of X# with regard to zero argument functions, so that the behavior is identical to Visual Objects.

 

Regardless of whether this option is enabled or not, the CLIPPER and STRICT keywords can always be used to explicitly specify the desired calling convention.

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

FUNCTION foo() // CLIPPER
? pcount(), _getFParam( 1 )
RETURN
 
FUNCTION Start() AS VOID
foo( 1 )
RETURN

 

 

The above example will compile and run correctly if -vo5 is used, or if the CLIPPER keyword is added at the end of the FUNCTION foo() declaration. Otherwise, a compiler error will be generated on the call to foo(), as well as on the calls to pcount() and _getFParam() (which are illegal in a STRICT calling convention function).