xc file not building with cpp headers

Technical questions regarding the XTC tools and programming with XMOS.
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

xc file not building with cpp headers

Post by Bambus »

Hi everyone,

I am trying to implement a direction finding technique on an xmos board using root-MUSIC. I implemented root-MUSIC using the Eigen project. When I try to build a cpp file including the root-MUSIC header file, everything works fine. But when I include the same header file in my xc file and try to build the xc file, I get errors such as:

../src/root_music.h:15:10: fatal error: 'vector' file not found
../src/root_music.h:19:7: error: parse error before "namespace"
using namespace Eigen;
../src/root_music.h:23:11: error: parse error before ':' token
static std::vector<double> root_music(std::complex<double> *signals, int const nsamples, int const nsensors, double k_f, double d)
../src/root_music.h:37:35: error: parse error before '++' token
for(int i = 0; i< n_sensors; i++) {

I have tried finding a solution to this problem in this forum but nothing has resolved my issue, yet. I am using xTIMEcomposer: Community_14.2.3 (build 15642, Oct-17-2016) on Mac OS X Sierra.

Thank you for your help!
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

Hi,
I am not familiar with your particular situation, but in general C, C++, and XC are different languages with some overlap.
There is a subset (e.g. basic types and function definitions) that all languages understand and agree upon.
XC will certainly get upset with C++ template and namespace syntax - as in your example.
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

Hi Robert,
Can you not refer me to some document or give me any other resource that might help me find the solution?

Thank you!
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

XC files can't directly include or call the C++ code in your header file.
You need to include the c++ header in a cpp file and write C++ code to access the root_music stuff.
This C++ file can then make available 'simple function calls' that can be called by XC files.
These 'simple function calls' will conform to the xcore ABI.
For more info search 'xmos abi'
Bambus
Member++
Posts: 27
Joined: Tue Feb 28, 2017 12:52 pm

Post by Bambus »

Thank you Robert, I will dig into it and give some feedback if I can make it work.