I’m using A_DEFSYMBOL
when using A_DEFSYMBOL, you don't deal with t_atom*s; instead you get a t_symbol* directly. so there is no use for atom_getsymbol()
Ah!
for the moment and *s seems to print to console
??? how?
I mean this: in the case of [pclass D]
void *pclass_new(t_symbol *s) { post("%s", *s); //this prints “D” to the console }
but I can’t seem to figure out how to get type t_symbol into an array.
into an array of what? this doesn't make sense (and i suspect that this is why it doesn't work for you)
Perhaps my wording is confusing. I want to pass the string into an array of chars, eventually.
atom_string seems to work with A_GIMME but that seems redundant as I’m only passing one symbol.
a symbol is a pointer to a "t_symbol" struct. the t_symbol struct has a member "s_name" which is a pointer to a zero-terminated immubtale string. most likely this is what you want.
It is.
since symbols are statically allocated, this pointer will remain valid through the process's lifetime. so most likely, you don't want to "copy it to an array", but rather keep the pointer around and use it directly. there's only one exception to this: if you want to modify the string, then you *must* copy it first.
Yep! That’s what I want to do. What’s the easiest way to access and copy the string in this instance?
gfmdsar IOhannes
On 2017-01-11 06:37, Ricky Graham wrote:
void *pclass_new(t_symbol *s) { post("%s", *s); //this prints “D” to the console }
oh my!
how about, looking up the definition of t_symbol in m_pd.h? typedef struct _symbol { char *s_name; struct _class **s_thing; struct _symbol *s_next; } t_symbol;
so the *only* proper way to access the string within a symbol is by dereferencing the s_name member.
post("%s", s->s_name);
fgam,df IOhannes