I have a while (1) loop in my main.cpp file
while (1)
{
if (++i >= 2000000uL)
{
i = 0;
sprintf(debugStr, "Coffee from C++ function\n");
g_sci.Tx(debugStr, strnlen(debugStr));
printDummy(debugStr);
g_sci.Tx(debugStr, strnlen(debugStr));
}
}
my printDummy function is a C function in a separate C file. I used the extern "C" keywork in my main.cpp file.
extern "C" {
#include "dummy.h"
}
void printDummy(char * dummy)
{
sprintf(dummy, "Coffee from C function\n");
}
The printf from the C++ code works fine. However, the printf from the C code writes some random values in the string.
I have open source C code that I need to debug so that's why I used the sprintf function from both C and C++ code.
I'm puzzled. This should work. The code compiles and links just fine.
I'm using the TI v22.6.0.LTS compiler in the legacy COFF mode.
My stack size is 0x2000 and heap size is 0x2000. Printf is enabled with the "nofloat" switch.
Regards