int main() { // instantiate your global robot object robot = new_robot(4); robot.create.connect(); robot.controller.motor(0, 80); robot.an_instance_method(); printf("%d", robot.a_property); robot.create.disconnect(); return 0; }
// this creates a thread for the robot that we're adding and starts it int add_robot(void (*robot_controller)(), robot_t * robot) { robot_t default_robot; if(robots_size >= MAX_ROBOTS || robot_controller == NULL) return 0; if(robot == NULL) { robot = &default_robot; new_robot(robot, robots_size); } robots[robots_size] = *robot; if(pthread_create(&robot_threads[robots_size], NULL, start_robot, robot_controller)) return 0; robots_size++; return 1; }