C Modules compiled as C++
Posted: Mon Mar 23, 2020 2:13 pm
Hi,
I've got a bunch of code and utilities that I'd like to tap into from MicroPython. This functionality is accessed through some c++ header files.
Unfortunately, by default the C Modules (like the name) are C only. I could create an intermediary layer that would wrap a c++ function util::math::add(int,int) to util_math_add(int, int) but that add development and runtime overhead and doesn't allow me to use class objects in the C modules.
An ideal solution would be to have the C modules be compiled as C++ and for certain functions to be made C compatible by using extern "C".
I've given this a try by using extern "C" and changing the makefile to compile with g++ however the makefiles don't seem to be designed for this.
Has anyone given this a try before or knows if it's possible or not?
Thanks
I've got a bunch of code and utilities that I'd like to tap into from MicroPython. This functionality is accessed through some c++ header files.
Unfortunately, by default the C Modules (like the name) are C only. I could create an intermediary layer that would wrap a c++ function util::math::add(int,int) to util_math_add(int, int) but that add development and runtime overhead and doesn't allow me to use class objects in the C modules.
An ideal solution would be to have the C modules be compiled as C++ and for certain functions to be made C compatible by using extern "C".
I've given this a try by using extern "C" and changing the makefile to compile with g++ however the makefiles don't seem to be designed for this.
Has anyone given this a try before or knows if it's possible or not?
Thanks