I know of no other way, aside from using a script to put those guards on
all the headers. Note however that they only need to go on the public
include headers (include/), not the private headers in the src
directories.
There is one other possibility. I don't think it is what you're asking
about, but I thought it was worth mentioning for completeness. If the
mynewt libraries were reduced to the subset of C and C++ (some people
call this "Clean C"), then everything could be built with a C++
toolchain. In this case, there would be no need for the extern "C"
guards. I don't particularly care for this solution personally, as
there are a few annoying differences between the languages (one of the
biggest being that C++ does not support the implicit conversion to and
from void*).
Chris
On Sat, Apr 09, 2016 at 08:18:00AM -0700, Sterling Hughes wrote:
> Hi,
>
> I recently talked with a user of Mynewt, and they were trying to get our
> system header files into a C++ project.
>
> I'm wondering if folks on the list know a better way of doing this, than
> just manually going to every header file and adding:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> #ifdef __cplusplus
> }
> #endif
>
> If not, I guess we should probably go ahead and do that.
>
> Sterling