Calling QT c++ function from a c function: undefined reference
Solved
General and Desktop
-
Hi all
I am using two source code files - one with c code and the other with c++ code as well as using both c and c++ libraries.The main function is c++ code. In the additional functions that i have written, I want to call c functions from some c++ functions and vice-versa.
I have defined the function (send_using_qtserial) to be called from a C file as this in my MainWindow.cpp
extern "C" size_t MainWindow::send_using_qtserial(uint8_t *data, size_t len) { return serial->write((const char *)data, (qint64)len); }
I have called that function in Protocol.c as follows:
extern size_t send_using_qtserial(uint8_t *data, size_t len); size_t UART_Write_Out(const USART_MODULE_ID id, void * source, size_t nBytes) { uint8_t *data= (uint8_t*)source; return send_using_qtserial(data, nBytes); }
Unfortunately, I cannot seem to call a c++ function from a c function. I get the
the build error 'undefined reference to 'send_using_qtserial'' error for the c++ function in the c function I am trying to call it from.Any suggestions?
-
-
P Pl45m4 referenced this topic on