xsharp.eu • FOX2 compiler switch
Page 1 of 1

FOX2 compiler switch

Posted: Tue Oct 26, 2021 6:20 pm
by Karl-Heinz
Hi Robert,

Code: Select all

FUNCTION Start( ) AS VOID 

	? Test( 2 ) 
	
RETURN    

FUNCTION Test( n  )
	
	RETURN n + 12 
1. given is /memvar+ and nothing else.

The code compiles without warnings and runs as expected

2. now add /Fox2+

the compiler throws the error XS0103: The name 'Test' does not exist in the current context

3. now add /undeclared+

the compiler throws the warning XS9073: Variable 'Test' has not been declared. Assuming this is a FIELD
or a MEMVAR.

The code runs as expected

Are these compiler switch dependencies by design ?

regards
Karl-Heinz

FOX2 compiler switch

Posted: Tue Oct 26, 2021 7:59 pm
by robert
Karl-Heinz,

Yes, this is by design.
The /fox2 compiler option tells the compiler that "Test(2)" could be a function call but could also be accessing an array element in a public/private variable "Test" when that was declared outside of the scope of the method where it is defined.
To be able to access that memvar you will either have to declare it (MEMVAR Test) or you will have to enable /undeclared.

Robert