Hi… i am working with ESp32 and Arduino framework on platformio,
I found many libs in pure C…
Is there a simple way to integrate them in c++ projects.
keep in mind that all my files have externsion .cpp
Thanks
Hi… i am working with ESp32 and Arduino framework on platformio,
I found many libs in pure C…
Is there a simple way to integrate them in c++ projects.
keep in mind that all my files have externsion .cpp
Thanks
Many C libraries might already be interoperable with C++ because their header files have the correct logic in them to add extern "C" { .. }
to the function and struct declarations, through which they become callable in C.
#ifndef HEADER_GUARD_H_
#define HEADER_GUARD_H_
#ifdef __cplusplus
extern "C" {
#endif
// actul header content
#ifdef __cplusplus
}
#endif
#endif // HEADER_GUARD_H_
See Standard C++.
If they do not have the extern "C"
declaration, you can either add them in when your code includes them…
extern "C" {
#include "some_pure_c_lib.h"
}
or you edit the libraries accordingly.