FOX2 compiler switch

This forum is meant for questions about the Visual FoxPro Language support in X#.

Post Reply
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

FOX2 compiler switch

Post 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
User avatar
robert
Posts: 4519
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FOX2 compiler switch

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply