[PD-dev] Converting arbitrary strings to symbol in an external

Chuckk Hubbard badmuthahubbard at gmail.com
Sat Mar 23 17:31:35 CET 2019


I love you guys!

On Fri, Mar 22, 2019, 7:13 PM Christof Ressi <christof.ressi at gmx.at> wrote:

> > means it can only take an actual hardcoded string.
>
> if with "hardcoded" you mean a string constant, then the answer is no. "s"
> is a pointer to any c string, the const part only means that gensym()
> promises not to modify the string.
> google "const correctness".
>
> > Can this convert floats to symbols?
>
> use a char array together with snprintf, e.g.:
>
> char buf[100];
> snprintf("foo-%f", sizeof(buf), someFloatValue); // NOTE: you should check
> the return value, if you want to be safe, see
> https://linux.die.net/man/3/snprintf
> gensym(buf);
>
> Christof
>
>
>
> *Gesendet:* Freitag, 22. März 2019 um 17:31 Uhr
> *Von:* "Chuckk Hubbard" <badmuthahubbard at gmail.com>
> *An:* Pd-dev <pd-dev at iem.at>
> *Betreff:* Re: [PD-dev] Converting arbitrary strings to symbol in an
> external
> Thank you.
> I have read it.
> I understood that the "const" part of "const char *s) means it can only
> take an actual hardcoded string. Can this convert floats to symbols?
>
> On Fri, Mar 22, 2019, 4:19 PM Claude Heiland-Allen <claude at mathr.co.uk>
> wrote:
>
>> Hi Chuckk,
>>
>> On 22/03/2019 13:59, Chuckk Hubbard wrote:
>> > Can I convert char[] to symbol?
>> t_symbol *gensym(const char *s);
>>
>> recommended reading:
>> https://github.com/pure-data/externals-howto
>>
>>
>> Claude
>> --
>> https://mathr.co.uk
>>
>>
>>
>>
>> _______________________________________________
>> Pd-dev mailing list
>> Pd-dev at lists.iem.at
>> https://lists.puredata.info/listinfo/pd-dev
>
> _______________________________________________ Pd-dev mailing list
> Pd-dev at lists.iem.at https://lists.puredata.info/listinfo/pd-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20190323/dca8c5cf/attachment.html>


More information about the Pd-dev mailing list