Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
This simple test gives me all kinds of errors. I did not include main as it simply calls dotest() from Module 2.
- Cannot use private enum as return type of private function
- Private structure definition is not exported into C code
- byref structure member produces several warnings and errors
' error: a Public variable cannot have a type that is a Private enumeration
private enum Position
Up
Down
end enum
' error: unknown type name 'mzs_Info'
' note: expected 'struct zc_Reader *' but argument is of type 'struct zc_Reader **'
private structure Info
dim r as Reader byref
end structure
' error: called object 'zf_6Reader_read((struct zc_Reader *)&mzv_sobject.zm_r)' is not a function
private function test(byref i as Info) as Position
test = CType(sobject.r.read(), Position)
end function
' warning: passing argument 1 of 'zc_6Reader__Create' from incompatible pointer type [enabled by default]
private sobject as Info
public sub dotest()
sobject.r.DataAddress = robject.DataAddress
Debug.print CStr(test(sobject))
end sub
Hi Don,
I run the test above and the one from e-mail through 4.3.4 compiler, no errors. Awesome job, thanks! Now I have more for you to tackle:
"Error: the invocation of function "CheckRange" does not match any available candidates"
Commenting out CheckRange(integer) removes error. Interesting that moving code into one file with Main() also removes problem.
public SLift as Sensor
public class Sensor
end class
public sub CheckRange(byval p as integer)
end sub
public sub CheckRange(byref s as Sensor)
end sub
public sub CheckSensors()
call CheckRange(SLift)
end sub
Looks like I spoke prematurely about the first test on this thread. While new compiler does not report any errors, the program does not work either.
When it comes to initializing byref field of the structure the controller resets, so the program goes into permanent reboot loop.
Yet another problem that I found during live test is that private variables are not initialized properly. To test add this to module 2:
wwwoholic wrote:When it comes to initializing byref field of the structure the controller resets, so the program goes into permanent reboot loop.
The test case seems to execute properly. Do you have one that exhibits the problem that you mention.
As an aside, it is important to note that the ByRef field is initialized to zero when an instance of an Info structure is created. Invoking the test() function before setting the r member to a valid address will probably cause a reboot.
I think it was my fault with byref. The code I have is: sobject.r = robject
while I should have used sobject.r.DataAddress = robject.DataAddress
One should not write programs in 3 languages at the same time...