What I am doing wrong with a class? ( a strange compiler error)
pik33
Posts: 2,366
I am getting a strange compilation error while trying to compile the code containing a class using another class. As the original code is too long, I extracted simple examples.
(1). This compiles:
dim psram as class using "psram4.spin2" psram.fill(0,123,1,0,1)
(2) This doesn't compile:
dim psram as class using "psram4.spin2" class f dim a as integer sub b psram.fill(0,123,1,0,1) end sub end class psram.fill(0,123,1,0,1)
error: Unable to determine class type
at psram.fill in sub b
So it doesn't recognize "psram" if used in another class. So I tried to declare it inside the class
dim psram as class using "psram4.spin2" class f dim psram as class using "psram4.spin2" dim a as integer sub b psram.fill(0,123,1,0,1) end sub end class psram.fill(0,123,1,0,1)
This time the error I got is totally stupid:
Unable to open file `psram4.spin2': No such file or directory test003.bas |-psram4.spin2 |-|-psram4drv.spin2 child process exited abnormally
What's wrong? There already IS the psram4.spin2 in the directory.
This is not a duplicate file use problem as this example:
class f dim psram as class using "psram4.spin2" dim a as integer sub b psram.fill(0,123,1,0,1) end sub end class
gives the same error:
Unable to open file `psram4.spin2': No such file or directory
Tested in 5.9.10 and 5.9 11 (fresh complied)
Comments
Worked around:
dim psram as class using "/home/pik33/Programowanie/P2-retromachine/Propeller/Videodriver develop/psram4.spin2"
A full path did the trick. Why?
If I set a starting directory to the project directory it also compiles
Summary as it is now:
Adding class using "filename" in a program works, opens and compiles the file in the current project directory. But if the declaration is inside a class, then it searches the file not in the project directory, but in the directory from where Flexprop was started. The re are 2 workarounds (1) use absolute path to the file (2) start Flexprop from inside the project directory.
If all the classes are declared as "class using" then it may work -- that is, if you put your basic class into a file "f.bas" and include it with
class using "f.bas"
then I'm guessing it'll work as expected, since it'll be going through the same path as Spin objects. BASIC classes declared "inline" are supposed to work, but they're kind of an exception and not tested as well as classes that are stored in files.The next strange thing:
/home/pik33/Programowanie/P2-retromachine/Propeller/Videodriver_develop/windows.bas:30: warning: signed/unsigned comparison may not work properly
Where is the signed/unsigned comparison when l,h,xx,yy are ulongs ?
Unsigned compare of
(xx>=0)
will always be true. Optimiser should eliminate the compare, but0
will be signed by default me thinks.In the declaration:
xx
has no explicit type and defaults tointeger
. That is, the parsing of types in parameter lists does not extend across commas.Too much Pascal programming before where procedure putpixel (xx,yy:cardinal, c:byte) makes both xx and yy unsigned
i got same error. how can i solve this? myfiosgateway.com
mobdro
There are several errors discussed in this thread... which one are you getting? And which version of FlexProp are you using?