Use lib_xcore_c from c++

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
jorsc
Junior Member
Posts: 7
Joined: Fri May 05, 2017 1:39 pm

Use lib_xcore_c from c++

Postby jorsc » Mon Mar 12, 2018 1:00 pm

I'm attempting to use some functions from lib_xcore_c from a c++ file but get compilation errors (same error on several lines) in xcore_c_chanend.h as:
..
xcore_c_chanend.h:28:3: error: cannot initialize return object of type 'xcore_c_error_t' with an lvalue of type 'unsigned int'
...
on top of these I also get an error:
xccompat.h:196:18: error: redefinition of 'clock' as different kind of symbol

I successfully invoked lib_xcore_c functions from a c file so I assume the above errors appears from the fact that lib_xcore_c is compiled through the c++ compiler.

I attempted to create a Makefile for lib_xcore_c and link it to my c++ file as binary lib but I can't make this work either.

Anyone has a workaround or suggestion on this?
jorsc
Junior Member
Posts: 7
Joined: Fri May 05, 2017 1:39 pm

Postby jorsc » Mon Mar 12, 2018 4:17 pm

Answering myself...
I managed to work around the issue by creating a separate c module and expose my calls to lib_xcore_c from this module. This way the c compiler is invoked.

From my c++ file I can then access the functions from my c module using:
extern "C" {
#include "my_xcore_c.h"
}

Who is online

Users browsing this forum: No registered users and 20 guests