cog_run and C++ projects
If I attempt to use a project using the C++ compiler, I get errors spit out from any use of cog_run with any variety of function I try. Standard functions, static class functions, extern "C" wrapped functions. All produce the error:
naturally, putting in -fpermissive in compiler options converts these from errors to warnings but that doesn't mean it's going to work. This error will happen to any C++ project I start even the simple examples from the multicore folder.
Is that part of the library a bust for C++ projects? Do I just have to live with the warnings.
As my ugly workaround to calling a class member function in a C callback I created a global variable that I store the object I want to launch into. In the class header is standard function with no return value or parameters like this
Calling that function like thus:
should callback that function which does:
Also, if the function that is run by cog_run() terminates under some condition, does the cog get stopped? I would assume so, but the description doesn't specify.
error: invalid conversion from void (*) () to void (*) (void*) [-f permissive] error: initializing argument 1 of 'int* cog_run(void(*)(void*), int) [-fpermissive]
naturally, putting in -fpermissive in compiler options converts these from errors to warnings but that doesn't mean it's going to work. This error will happen to any C++ project I start even the simple examples from the multicore folder.
Is that part of the library a bust for C++ projects? Do I just have to live with the warnings.
As my ugly workaround to calling a class member function in a C callback I created a global variable that I store the object I want to launch into. In the class header is standard function with no return value or parameters like this
void launchObject();
Calling that function like thus:
g_p_object_to_launch = &myObject; cog_run(launchObject, 128);
should callback that function which does:
g_p_object_to_launch->run();and the run() method then gets everything setup I/O wise and begins running an endless loop.
Also, if the function that is run by cog_run() terminates under some condition, does the cog get stopped? I would assume so, but the description doesn't specify.
Comments
Instead, checkout PropWare's Runnable class.
I'm biased toward using PropWare, so of course I recommend using the whole thing, but if are happy with your current workflow, simply download runnable.h and include it in your project. It does not have any dependencies on other PropWare classes so it's very easy to add to other projects.
Thanks again for sharing!