Message ID | 1576085181-10378-1-git-send-email-pjtexier@koncepto.io |
---|---|
State | Accepted |
Headers | show |
Series | [libubootenv] libuboot: wrap libuboot in extern "C" for C++ | expand |
On 11/12/19 18:26, 'Pierre-Jean Texier' via swupdate wrote: > This allows linking from C++ applications without the need of using > extern "C" when including libuboot header file. > This follows the guide line of many other libraries. > > Fixes: > > foo.cpp:(.text+0x19) : undefined reference to « libuboot_initialize(uboot_ctx**, uboot_env_device*) » > ... > > Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io> > --- > src/libuboot.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/src/libuboot.h b/src/libuboot.h > index 227e022..e55b149 100644 > --- a/src/libuboot.h > +++ b/src/libuboot.h > @@ -5,6 +5,9 @@ > * SPDX-License-Identifier: LGPL-2.1-or-later > */ > > +#ifdef __cplusplus > +extern "C" { > +#endif > > #pragma once > > @@ -153,3 +156,7 @@ const char *libuboot_getname(void *entry); > * @return pointer to name or NULL > */ > const char *libuboot_getvalue(void *entry); > + > +#ifdef __cplusplus > +} > +#endif > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/src/libuboot.h b/src/libuboot.h index 227e022..e55b149 100644 --- a/src/libuboot.h +++ b/src/libuboot.h @@ -5,6 +5,9 @@ * SPDX-License-Identifier: LGPL-2.1-or-later */ +#ifdef __cplusplus +extern "C" { +#endif #pragma once @@ -153,3 +156,7 @@ const char *libuboot_getname(void *entry); * @return pointer to name or NULL */ const char *libuboot_getvalue(void *entry); + +#ifdef __cplusplus +} +#endif
This allows linking from C++ applications without the need of using extern "C" when including libuboot header file. This follows the guide line of many other libraries. Fixes: foo.cpp:(.text+0x19) : undefined reference to « libuboot_initialize(uboot_ctx**, uboot_env_device*) » ... Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io> --- src/libuboot.h | 7 +++++++ 1 file changed, 7 insertions(+)