From another thread: http://e2e.ti.com/support/development_tools/compiler/f/343/p/228422/1002585.aspx#1002585
Archaeologist said:
For the TI compiler, the pragma syntax is different between C and C++, and even an 'extern"C"' block won't patch over this difference.
Create a separate C source file in your project and compile it as C code. Place all references to mathlib.h in that file. You can create wrapper functions which make direct calls to mathlib.h features, and then call those wrapper functions from your C++ code.
Could you please tell me exactly which file line 821 is in, and what the exact text of the pragma on that line is? This is something that can be worked around by changing mathlib.h to be sensitive to whether it is being compiled for C++, but there are probably other things that need to be adjusted.
I am trying to follow this advice to use MATHLIB in a simple c++ program. I am still getting 50 pragma-related errors in CCS, even after creating the wrapper function for the MATHLIB division function. Here's my simple test code:
***** In CJmathlib.c
#include <mathlib.h>
#include "divsp.h"
float CJdivide (float a, float b) {
float d;
d = divsp(a,b); // "C" function! (NOT c++)
return d;
}
***** In main.cpp
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <CJmathlib.c>
/*
* main.cpp
*
* This program is to test the TI MATHLIB library
*/
int main(void) {
float a = 1.23456;
float b = 9.87654;
float c;
c = b / a;
printf("Result: %f",c);
// *********************************************
float asdf;
asdf = CJdivide(b, a);
printf("Result: %f",asdf);
return 0;
}
Am I correctly implementing the wrapper function for the MATHLIB divsp() function? I have never merged c & c++ before, I greatly appreciate any thoughts on this work-around. Thanks!
