tinkersprojects / G-Code-Arduino-Library

Allows any machines and robots to be controlled by G-Code
GNU General Public License v3.0
52 stars 18 forks source link

Function moviment() is a member of a class #11

Closed ProtopIazma closed 4 years ago

ProtopIazma commented 4 years ago

Hi. How do I write code correctly if the function moviment() is a member of a class? For example in this case: class Moving { public: void gotoLocation(double f,double x,double y,double z,double e); void moviment(); } ArmMoving; commandscallback commands[1] = {"G0",ArmMoving.moviment}; gcode Commands(1,commands);

The compiler writes the following error: *cannot convert 'Moving::moviment' from type 'void (Moving::)()' to type 'CallbackFunction {aka void ()()}'**

tinkersprojects commented 4 years ago

i'm looking into it but for the time being, you can just use a void function with the class function in it. ` class Moving { public: void gotoLocation(double f,double x,double y,double z,double e); void moviment(); } ArmMoving;

void moviment() { ArmMoving.moviment }

commandscallback commands[1] = {"G0",moviment}; gcode Commands(1,commands); ` its a bit annoying but it will work until the other is worked out.

ProtopIazma commented 4 years ago

Thank. I would be thankful. I tried to pass this function through the pointer, but then the compiler writes an error about type mismatch.

ProtopIazma commented 4 years ago

Sorry, but the compiler for such a line: ArmMoving.moviment; Produces such an error: invalid use of non-static member function 'void Moving::moviment()'