Hi,
I have many many warnings, when I compiling my program.
All warnings are two types :
[Warning] INFOKAT.PRG(22): XBT0103: Ambiguous variable reference, assuming MEMVAR verzia
and
[Warning] INFOKAT.PRG(267): XBT0102: Ambiguous variable reference fontbt
I have in MAIN() define PUBLIC variable like this :
PUBLIC verzia
and then in source have for example this :
verzia="Version 2.0"
or PUBLIC abc[2]
and later in some function :
abc[1]:="alfastring"
abc[2]:="betastring"
what is wrong in this ?
I tryed also write :
PUBLIC verzia:=""
and next
verzia:="Version 2.0", but no effect
when write
PUBLIC verzia:="Version 2.0", in this case no warning.
can I ignore all ?
Victorio.
Ambiguous variables
Re: Ambiguous variables
You are using the /W switch of the compiler.
This forces the compiler to warn you that you have variables which may not be defined.
This only happens with private and public variables and field names.
It is always a good idea to declare all variables as LOCAL if you don't want these warnings.
You can also turn off the warnings by removing the /W option from your project file.
True compilers try to resolve everything during compiling to prevent runtime errors.
This is true of C and C++.
Xbase++, on the other hand, is compatible with Clipper legacy code and therefore it must allow variables to be created at runtime.
There are many advantages to this capability, but also disadvantages because the programmer cannot always prevent coding errors.
Ambiguous warnings are not an indication that your code will fail. It only is an indication that the compiler does not know the origin of the variable. Private and Public variables should be used rarely.
This forces the compiler to warn you that you have variables which may not be defined.
This only happens with private and public variables and field names.
It is always a good idea to declare all variables as LOCAL if you don't want these warnings.
You can also turn off the warnings by removing the /W option from your project file.
True compilers try to resolve everything during compiling to prevent runtime errors.
This is true of C and C++.
Xbase++, on the other hand, is compatible with Clipper legacy code and therefore it must allow variables to be created at runtime.
There are many advantages to this capability, but also disadvantages because the programmer cannot always prevent coding errors.
Ambiguous warnings are not an indication that your code will fail. It only is an indication that the compiler does not know the origin of the variable. Private and Public variables should be used rarely.
The eXpress train is coming - and it has more cars.
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Ambiguous variables
If you want to get right of the warnings and need to have the private/public variables, make them not ambigous.
For example.
PUBLIC pubvar
PRIVATE memvar
memvar := 'A' // generates warning
pubvar := 'B' // generates warning
m->memvar := 'A' // no warning
m->pubvar := 'B' // no warning
REPLACE dbffield with m->memvar // generates warning
REPLACE ALIASNAME->dbffield with m->memvar // no warning
We have old code in our application that we have not converted to use locals. New code uses local. This removes the warnings as we always compile with the /w flag on to catch some typo type errors.
For example.
PUBLIC pubvar
PRIVATE memvar
memvar := 'A' // generates warning
pubvar := 'B' // generates warning
m->memvar := 'A' // no warning
m->pubvar := 'B' // no warning
REPLACE dbffield with m->memvar // generates warning
REPLACE ALIASNAME->dbffield with m->memvar // no warning
We have old code in our application that we have not converted to use locals. New code uses local. This removes the warnings as we always compile with the /w flag on to catch some typo type errors.
Re: Ambiguous variables
as Roger say : it is just a Warning.
if you want to get rid of the Warning you have to write MEMVAR before declare
if you want to get rid of the Warning you have to write MEMVAR before declare
Code: Select all
MEMVAR verzia
PROCEDURE MAIN
PUBLIC verzia
greetings by OHR
Jimmy
Jimmy
Re: Ambiguous variables
I will try it, thank you.
I was thinking then also warning can cause some incorrect behavior at runtime.
I was thinking then also warning can cause some incorrect behavior at runtime.
Re: Ambiguous variables
it it's a misspelled variable, then you will have a problem at runtim..Victorio wrote:I will try it, thank you.
I was thinking then also warning can cause some incorrect behavior at runtime.
if it's a public or private variable that you haven't prefixed with m-> then you should be ok..
I leave the /w switch on. it warns me about misspellings, and that saves a lot of time.
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises