Forums > Dev

std library use in C++ external (eg std::string and std::stoull)

July 3, 2013 | 5:55 pm

for synchronisation, I need to send an unsigned long long to my external. I currently compile as .cpp (which works fine if you simply cast the object as a (t_object*))
however, although I can get the unsigned lon long into the object (as a message)
I can;t seem to convert it to unsigned long long using std::stoull
and std::string also gives problems
why is that? how could the standard library added/used?
or is tehre a workaround?

void synchroniser_offset(t_synchroniser *x, t_symbol *s, long argc, t_atom *argv)
long i;
t_atom *ap;

post("message selector is %s",s->s_name);
//here s->s_name is the value I’m interested in converting to unsigned long long



July 3, 2013 | 6:07 pm

okay, so I seem to have got somewhere using;


post("message selector is %s",s->s_name);
unsigned long long ul = strtoull (s->s_name, NULL, 0);
post("unsigned %llu ", ul);

perhaps it’s using the C version of the standard library?
being careful to use C-string types, not std::string s?

but the code above works. Any comments appreciated though so I understand why the issue arose.

May 21, 2015 | 6:06 am

more of a postscipt here, in case anyone comes across this, you cast to a t_class not a t_object to use cpp within max external:

t_myobject *x = (t_myobject *)object_alloc((t_class*)myobject_class)

and the external is [myobject]

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Dev