Show/Hide Toolbars

XSharp

Passing a NULL pointer to a REF variable is allowed (with /vo7) but strongly discouraged.
You MUST make sure that the function being called does a check for NULL pointers for the REF parameter.

The following code shows how you should add a test to the function being called

 
FUNCTION Start() AS VOID
  LOCAL n AS INT
  n := 1
  ? TempRef(10 , n)     // 11
  ? TempRef(10 , NULL)     // 1976
 
RETURN
 
FUNCTION TempRef(a AS INT, r REF INT) AS INT
  IF @r == NULL         // Check for NULL pointer!
    RETURN 1976
  END IF
RETURN a + r