Hi Peter,
This is likely related to a change we made to the compiler when it is using v40 onwards.
Historically, we forced all files to be compiled as cpp, whether the extension was .c or .cpp. This was originally meant to avoid confusion with c and cpp linkage (i.e. name mangling), but as people have started importing large existing C codebases, it turns out this non-standard behaviour was a mistake. As such, from v40 onwards, we now compile .c files as C, and .cpp files as C++, providing a more standard behaviour.
This is almost certainly the reason you are getting undefined symbols; you have some functions that in C files that are being called by C++ files, but the headers don't define the functions as extern "C"
, so they don't match up at link time.
What you generally want to do to fix this is:
- Rename .c files as .cpp, so they get compiled as C++ as before
- Mark the functions in .h headers of .c files as being C linkage, so when included by C++ files you get the right result. i.e:
// my C .h header file
#ifdef __cplusplus
extern "C" {
#endif
void my_c_function();
#ifdef __cplusplus
}
#endif
For more about name mangling, see:
Hope that helps!
Simon
After some time i reopen one of my projects which is using the old network stack. I update the mbed lib and run into some errors. Starting with version 40 i get some undefined symbols by linking the NetServices. dns_setver() ...