[flext] Pass pointer from one external to another

Thomas Grill gr at grrrr.org
Fri Apr 17 07:47:44 UTC 2015


Hi Patrick,
while passing around pointer can be a pretty dangerous thing to do, it is actually done, e.g. by my vasp external library.
The pointer atom types in Pd and flext are intended to be used with Pd data structures, not for general C memory pointers.
The easiest way is to cast the pointer to a 64-bit unsigned integer, and convert this again into a numerical representation supported by Pd. Since Pd doesn't support integers you have to split the possibly 64 bit wide pointer address into multiple integers with at most 23 binary digits (that's the mantissa size of a single precision float). You can, e.g., use a list of three integers with 22 bits each.
I hope this helps, best,
Thomas
--
Thomas Grill
http://grrrr.org



Am 16.04.2015 um 19:56 schrieb Patrick Gampp <Patrick.Gampp at posteo.de>:

> Hi flext list,
> 
> I want to pass a pointer from one pd flext external to another. The pointer points to a parameter struct, which is used by both externals.
> 
> So far, I found SetPointer(t_atom &a,t_gpointer *p), which I thought can help me. But I cannot manage to put my pointer into the function.
> 
> Here is an example what I want:
> 
> myStructType myStruct;
> Atomlist myList(10);
> SetPointer(myList[0], &myStruct); // does not work since &myStruct is not of type *t_gpointer.
> 
> How can I manage to put &myStruct into the atomlist? Or is there another way to pass pointers from one external to another?
> 
> Cheers and thanks in advance,
> Patrick
> _______________________________________________
> http://grrrr.org/ext/flext
> 
> flext mailing list
> flext at grrrr.org
> http://grrrr.org/cgi-bin/mailman/listinfo/flext

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://grrrr.org/pipermail/flext/attachments/20150417/16e71f4e/attachment.sig>


More information about the flext mailing list