Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

FOX2 compiler switch 26 Oct 2021 20:20 #20141

  • Karl-Heinz
  • Karl-Heinz's Avatar
  • Topic Author


  • Posts: 765
  • Hi Robert,

    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

    Please Log in or Create an account to join the conversation.

    Last edit: by Karl-Heinz.

    FOX2 compiler switch 26 Oct 2021 21:59 #20143

    • robert
    • robert's Avatar


  • Posts: 2974
  • 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

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1