Show/Hide Toolbars

XSharp

The -vo6 option directs the compiler to resolve typed function pointers to PTR.

Syntax

-vo6[+|-]

Arguments

+ | - Specifying +, or just -vo6, directs the compiler to resolve pointers that would resolve to typed function pointers in Visual Objects to PTR.

Remarks

X# does not supported typed function pointers. Existing Visual Objects code that declares typed function pointers will not compile in X#, unless the type is changed to PTR or IntPtr.

 

If this option is enabled and a pointer type cannot be resolved, the compiler will attempt to locate a function with the same name as the pointer type (without "PTR"). If found, the compiler will resolve the type to PTR. This allows existing Visual Objects code to be compiled without modification, at least as far as the variable declaration is concerned.

 

The pointer type may be used as an argument to CCallNative(), PCallNative() or CallManaged(), depending on the type of function the pointer points to.

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

The following code is valid in Visual Objects, but will not compile in X# unless -vo6 is used.

FUNCTION foo( x AS INT ) AS VOID
RETURN
 
GLOBAL pFoo AS foo PTR
 

Using /vo6 has the same effect as if the GLOBAL declaration were rewritten as:

GLOBAL pFoo AS PTR

 

 

Using -vo6 has the same effect as if the GLOBAL declaration were rewritten as:

 

 

GLOBAL pFoo AS PTR

 

Note that PTR does not have the same semantics as typed function pointers in Visual Objects. However, typed function pointers are primarily used as arguments to CALL(), CCALL() and PCALL() in Visual Objects, which are not supported in X#. They have been replaced with CCallNative(), PCallNative() and CallManaged(), which accept IntPtr arguments. The same end result (invoking a function indirectly through a pointer) is therefore possible in X# without typed function pointers.