Use lib_xcore_c from c++

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
jorsc
Member++
Posts: 21
Joined: Fri May 05, 2017 1:39 pm

Use lib_xcore_c from c++

Post by jorsc »

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
Member++
Posts: 21
Joined: Fri May 05, 2017 1:39 pm

Post by jorsc »

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"
}
Post Reply