Forums > Dev

graham wakefield maxcpp, REGISTER_METHOD issues

December 24, 2011 | 2:59 pm

I’m trying to use the c++ wrapper maxcpp and i have some problem with register methods.
With example.cpp and example~.cpp the only working register method is REGISTER_METHOD(Example, bang);

The other ones (REGISTER_METHOD_FLOAT, REGISTER_METHOD_INT) , don’t do anything at runtime.

In my patch two strange things occurs.
I can’t plug a float or an int on the leftmost inlet.
When i plug a float on the second inlet and change the value i have the following message:
Example~doesn’t understand "float"
(same problem with int and every other messages other than bang)

Any ideas ?

OSX 10.6.7
XCode 3.2.6
Last version of maxcpp


April 2, 2012 | 11:09 am

Hi Julien,

int and float are types and reserved words.
Replace the #METHOD in both macros like here below

#define INLET_LONG(CLASS, METHOD) class_addmethod(
(t_class *)CLASS::m_class,
(method)CLASS::InletLong< &CLASS::METHOD>::call,
#define INLET_FLOAT(CLASS, METHOD) class_addmethod(
(t_class *)CLASS::m_class,
(method)CLASS::InletFloat< &CLASS::METHOD>::call,

Functor in maxCppBase are defined like this

typedef void (T::*inletlong)(long inlet, long v);
template struct InletLong {
static void call(T * x, long v) { ((x)->*F)(proxy_getinlet((t_object *)x), v); }
typedef void (T::*inletfloat)(long inlet, double v);
template struct InletFloat {
static void call(T * x, double v) { ((x)->*F)(proxy_getinlet((t_object*)x), v); }

In your (derived) object, declare your method like in "main":
INLET_FLOAT(fdscales, float_inlet); // float is c++ reserved so REGISTER_METHOD_FLOAT is typed with "float"
INLET_LONG(fdscales, int_inlet); // int is c++ reserved so REGISTER_METHOD_LONG is typed with "int"

Your object method will look like :
void int_inlet(long inlet, long v) {
switch (inlet) {
case 0:
post("inlet 0 %ld",v);
case 1:
post("inlet 1 : %ld",v);


void float_inlet(long inlet, double v) {
your code

The int and float boxes will then be accepted by your object.

I have a ticket open on jdataview, if you can help …

April 7, 2014 | 10:07 am

I’ve the same problem as Julien. I’m not an expert in C++ template. I think there are Macros to update in the Maxcpp6.h .

Could you update your code to have more explanation ???

I try to archive this.
void testfloatplus2(long inlet, double v) {
outlet_float(m_outlet[0], v+2);
should have N+2 as output in the max environment.

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

Forums > Dev