moin Alain,

I've never passed pointers around between externals myself, but...

On 2007-06-22 04:57:35, <[EMAIL PROTECTED]> appears to have written:
> I am trying to send some data out of an outlet using a symbol pointer. I have 
> tried using sprintf like 
> martin suggested with little succes. I am sure I am the one doing something 
> wrong. I am getting a 
> pointer symbol but I am not able to convert the pointer back.  In external#1 
> I have:
> 
> The out ----------------
> IplImage *frame;
> char symstr[10];
> t_symbol *sym;
> sprintf(symstr, "%p", frame);
> sym = gensym(symstr);
> outlet_symbol(x->m_outFrames, sym);
> 
> With this I get an address like:
> symbol 0x1159da0

... looks kosher to me ...

> ...but on the conversion in external#2 I get the problem. The conversion 
> looks like:
> 
> The in-----------------------
> IplImage *in_frame;
> x->in_frame = (IplImage *)atol(s->s_name);
> post("frame %s", x->in_frame);
> post("symbol %s",s->s_name);
>
> ...with this I get this:
> frame (null)
> symbol 0x1159da0

first of all, you probably want to post("frame %p", x->in_frame), rather
than "%s".  Second, in the docs for my atol (here under linux|glibc), I see:

  -- Function: long int atol (const char *STRING)
     This function is similar to the `strtol' function with a BASE
     argument of `10', except that it need not detect overflow errors.
     The `atol' function is provided mostly for compatibility with
     existing code; using `strtol' is more robust.

... so if your atol() is similar, then trying to convert a hex string to
a pointer with atol() is an exercise in futility (since in general,
10!=16).  strtol() ought to work better, auto-detetcting the hex-iness
of the string by its '0x' prefix.  You might also just want to roll out
the big guns and use the "%x" format to scanf(), but strtol() is likely
to be the better way to go.

marmosets,
        Bryan

-- 
Bryan Jurish                           "There is *always* one more bug."
[EMAIL PROTECTED]      -Lubarsky's Law of Cybernetic Entomology

_______________________________________________
PD-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev

Reply via email to