Pointer to structure not recognised in parent code?
bob_g4bby
Posts: 522
I'm writing a buffer based driver for the HDaudio add-in kit. But I'm having trouble with pointers to structures. I bet it's a simple nooby's mistake. In the driver I have the following code:-
sigbuff mic1
sigbuff mic2
sigbuff linein1
sigbuff linein2
sigbuff lineout1
sigbuff lineout2
^sigbuff micbuff
^sigbuff lineinbuff
^sigbuff lineoutbuff
^long micsample
^long lineinsample
^long lineoutsample
pri changebuffers()
if buffercycle <> false
buffercycle := false
[micbuff] := @mic1
[micsample] := @mic2
[lineinbuff] := @linein1
[lineinsample] := @linein2
[lineoutbuff] := @lineout1
[lineoutsample] := @lineout2
else
buffercycle := true
[micbuff] := @mic2
[micsample] := @mic1
[lineinbuff] := @linein2
[lineinsample] := @linein1
[lineoutbuff] := @lineout2
[lineoutsample] := @lineout1
cogatn(buffchangealert) ' send ATN to all cogs runnning dsp to signal it's time to start a fresh cycle
' at 48 ksample/s that cycle time is 21.333 mS - to do all dsp
There are two buffer sets. So every time an input buffer becomes full of samples from the a/d, the buffer set is swapped over in method changebuffers. e.g. pointer micbuff either points to mic1 or mic2 buffer etc.
If I write in the library, the statement 'lineoutbuff := micbuff' the compiler seems to accept that.
However, in the parent file that instantiates the library as 'sigpump': If I write 'sigpump.lineoutbuff := sigpump.micbuff' , the compiler complains 'Expected an object constant, structure or method'
What needs changing so that latter statement is also accepted?
Hope I've shown enough for someone to spot the mistook. I can post the whole project if need be.
Cheers, Bob

Comments
Is it simply the case that no variable declared in a library can be accessed directly from the main program, but can only be read and written via suitable get/set methods?
Maybe not - Is it the case that a variable declared in a library can be used globally throughout a program unless declared 'static', in which case the variable's scope is limited to the file it's defined in.
With FlexSpin at least, I think if you want to use a pub/pri local instance of a structure that's defined in a child object file, you have to first use a syntax like:
obj child: "child.spin2" con struct lineoutbuff = child.lineoutbuffThen you can use it as if it were defined in the current file. It does seem to be accepted without that if you declare it in a VAR block like:
obj child: "child.spin2" var child.lineoutbuff some_other_nameAlthough it seems like it won't accept it if the instance is named the same as the structure definition name (IOW, it doesn't seem to like:
var child.lineoutbuff lineoutbuff)Cheers