AnsweredAssumed Answered

Calling C++ function from mqx_tasks.c

Question asked by George Sosnowski on Mar 11, 2014
Latest reply on Mar 11, 2014 by Jorge_Gonzalez

I'm running CW10.3 and I have an MQX-lite project for K20DN512VMD10. I'm trying to call a C++ function from the mqx_tasks.c Task1_task function.

I have declared a C++ function as extern "C" void func(int);, however I still am getting the error "undefined reference to 'func' in the mqx_tasks.c file.

Are there some compiler/linker settings that I need to modify to allow the recognition of C++ and linkage?

 

mqx_tasks.c:

void func(int)'

 

void Task1_task(uint32_t task_init_data)

{

     int counter = 0;

 

     while(1) {

          counter++;

    

          func(2);

     }

}

 

run.cpp:

extern "C" void func(int val) {

     int i=0;

    

     i = i + val;

}


Outcomes