[v2] Add cpp guards in IPC interface
diff mbox series

Message ID 20190731114818.11884-1-g.morand@scewo.ch
State Accepted
Headers show
Series
  • [v2] Add cpp guards in IPC interface
Related show

Commit Message

Guy Morand July 31, 2019, 11:48 a.m. UTC
This allows linking from CPP applications without the need of using
extern "C" when including swupdate header files, that is ugly. This
follows the guide line of many other libraries.

Signed-off-by: Guy Morand <g.morand@scewo.ch>
---
 include/network_ipc.h     | 14 +++++++++++---
 include/progress_ipc.h    | 10 ++++++++++
 include/swupdate_status.h |  8 ++++++++
 3 files changed, 29 insertions(+), 3 deletions(-)

Comments

Stefano Babic July 31, 2019, 12:02 p.m. UTC | #1
On 31/07/19 13:48, Guy Morand wrote:
> This allows linking from CPP applications without the need of using
> extern "C" when including swupdate header files, that is ugly. This
> follows the guide line of many other libraries.
> 
> Signed-off-by: Guy Morand <g.morand@scewo.ch>
> ---
>  include/network_ipc.h     | 14 +++++++++++---
>  include/progress_ipc.h    | 10 ++++++++++
>  include/swupdate_status.h |  8 ++++++++
>  3 files changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/include/network_ipc.h b/include/network_ipc.h
> index e41493c..a4ce763 100644
> --- a/include/network_ipc.h
> +++ b/include/network_ipc.h
> @@ -9,15 +9,19 @@
>  #ifndef _IPC_H
>  #define _IPC_H
>  
> +#include <stdbool.h>
> +#include "swupdate_status.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
>  /*
>   * Be careful to include further headers here. This file is the interface
>   * to external programs interfacing with SWUpdate as client, and further
>   * headers are not exported.
>   */
>  
> -#include <stdbool.h>
> -#include "swupdate_status.h"
> -
>  #define IPC_MAGIC		0x14052001
>  
>  typedef enum {
> @@ -78,4 +82,8 @@ int swupdate_image_write(char *buf, int size);
>  int swupdate_async_start(writedata wr_func, getstatus status_func,
>  				terminated end_func, bool dryrun);
>  
> +#ifdef __cplusplus
> +}   // extern "C"
> +#endif
> +
>  #endif
> diff --git a/include/progress_ipc.h b/include/progress_ipc.h
> index 2587cc7..2c242eb 100644
> --- a/include/progress_ipc.h
> +++ b/include/progress_ipc.h
> @@ -11,6 +11,11 @@
>  #include <stdbool.h>
>  #include <swupdate_status.h>
>  
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +
>  extern char* SOCKET_PROGRESS_PATH;
>  
>  /*
> @@ -44,4 +49,9 @@ int progress_ipc_connect_with_path(const char *socketpath, bool reconnect);
>  
>  /* Retrieve messages from progress interface (it blocks) */
>  int progress_ipc_receive(int *connfd, struct progress_msg *msg);
> +
> +#ifdef __cplusplus
> +}   // extern "C"
> +#endif
> +
>  #endif
> diff --git a/include/swupdate_status.h b/include/swupdate_status.h
> index a63595b..38811e3 100644
> --- a/include/swupdate_status.h
> +++ b/include/swupdate_status.h
> @@ -8,6 +8,10 @@
>  #ifndef _SWUPDATE_STATUS_H
>  #define _SWUPDATE_STATUS_H
>  
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
>  /*
>   * This is used to send back the result of an update.
>   * It is strictly forbidden to change the order of entries.
> @@ -33,4 +37,8 @@ typedef enum {
>  	SOURCE_LOCAL
>  } sourcetype;
>  
> +#ifdef __cplusplus
> +}   // extern "C"
> +#endif
> +
>  #endif
> 

This is ok, applied to -master, thanks !

Best regards,
Stefano Babic
Guy Morand July 31, 2019, 12:15 p.m. UTC | #2
It's a pleasure, all the best!

Guy

On Wed, Jul 31, 2019 at 2:02 PM Stefano Babic <sbabic@denx.de> wrote:
>
> On 31/07/19 13:48, Guy Morand wrote:
> > This allows linking from CPP applications without the need of using
> > extern "C" when including swupdate header files, that is ugly. This
> > follows the guide line of many other libraries.
> >
> > Signed-off-by: Guy Morand <g.morand@scewo.ch>
> > ---
> >  include/network_ipc.h     | 14 +++++++++++---
> >  include/progress_ipc.h    | 10 ++++++++++
> >  include/swupdate_status.h |  8 ++++++++
> >  3 files changed, 29 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/network_ipc.h b/include/network_ipc.h
> > index e41493c..a4ce763 100644
> > --- a/include/network_ipc.h
> > +++ b/include/network_ipc.h
> > @@ -9,15 +9,19 @@
> >  #ifndef _IPC_H
> >  #define _IPC_H
> >
> > +#include <stdbool.h>
> > +#include "swupdate_status.h"
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> >  /*
> >   * Be careful to include further headers here. This file is the interface
> >   * to external programs interfacing with SWUpdate as client, and further
> >   * headers are not exported.
> >   */
> >
> > -#include <stdbool.h>
> > -#include "swupdate_status.h"
> > -
> >  #define IPC_MAGIC            0x14052001
> >
> >  typedef enum {
> > @@ -78,4 +82,8 @@ int swupdate_image_write(char *buf, int size);
> >  int swupdate_async_start(writedata wr_func, getstatus status_func,
> >                               terminated end_func, bool dryrun);
> >
> > +#ifdef __cplusplus
> > +}   // extern "C"
> > +#endif
> > +
> >  #endif
> > diff --git a/include/progress_ipc.h b/include/progress_ipc.h
> > index 2587cc7..2c242eb 100644
> > --- a/include/progress_ipc.h
> > +++ b/include/progress_ipc.h
> > @@ -11,6 +11,11 @@
> >  #include <stdbool.h>
> >  #include <swupdate_status.h>
> >
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +
> >  extern char* SOCKET_PROGRESS_PATH;
> >
> >  /*
> > @@ -44,4 +49,9 @@ int progress_ipc_connect_with_path(const char *socketpath, bool reconnect);
> >
> >  /* Retrieve messages from progress interface (it blocks) */
> >  int progress_ipc_receive(int *connfd, struct progress_msg *msg);
> > +
> > +#ifdef __cplusplus
> > +}   // extern "C"
> > +#endif
> > +
> >  #endif
> > diff --git a/include/swupdate_status.h b/include/swupdate_status.h
> > index a63595b..38811e3 100644
> > --- a/include/swupdate_status.h
> > +++ b/include/swupdate_status.h
> > @@ -8,6 +8,10 @@
> >  #ifndef _SWUPDATE_STATUS_H
> >  #define _SWUPDATE_STATUS_H
> >
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> >  /*
> >   * This is used to send back the result of an update.
> >   * It is strictly forbidden to change the order of entries.
> > @@ -33,4 +37,8 @@ typedef enum {
> >       SOURCE_LOCAL
> >  } sourcetype;
> >
> > +#ifdef __cplusplus
> > +}   // extern "C"
> > +#endif
> > +
> >  #endif
> >
>
> This is ok, applied to -master, thanks !
>
> Best regards,
> Stefano Babic
>
> --
> =====================================================================
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> =====================================================================

Patch
diff mbox series

diff --git a/include/network_ipc.h b/include/network_ipc.h
index e41493c..a4ce763 100644
--- a/include/network_ipc.h
+++ b/include/network_ipc.h
@@ -9,15 +9,19 @@ 
 #ifndef _IPC_H
 #define _IPC_H
 
+#include <stdbool.h>
+#include "swupdate_status.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * Be careful to include further headers here. This file is the interface
  * to external programs interfacing with SWUpdate as client, and further
  * headers are not exported.
  */
 
-#include <stdbool.h>
-#include "swupdate_status.h"
-
 #define IPC_MAGIC		0x14052001
 
 typedef enum {
@@ -78,4 +82,8 @@  int swupdate_image_write(char *buf, int size);
 int swupdate_async_start(writedata wr_func, getstatus status_func,
 				terminated end_func, bool dryrun);
 
+#ifdef __cplusplus
+}   // extern "C"
+#endif
+
 #endif
diff --git a/include/progress_ipc.h b/include/progress_ipc.h
index 2587cc7..2c242eb 100644
--- a/include/progress_ipc.h
+++ b/include/progress_ipc.h
@@ -11,6 +11,11 @@ 
 #include <stdbool.h>
 #include <swupdate_status.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 extern char* SOCKET_PROGRESS_PATH;
 
 /*
@@ -44,4 +49,9 @@  int progress_ipc_connect_with_path(const char *socketpath, bool reconnect);
 
 /* Retrieve messages from progress interface (it blocks) */
 int progress_ipc_receive(int *connfd, struct progress_msg *msg);
+
+#ifdef __cplusplus
+}   // extern "C"
+#endif
+
 #endif
diff --git a/include/swupdate_status.h b/include/swupdate_status.h
index a63595b..38811e3 100644
--- a/include/swupdate_status.h
+++ b/include/swupdate_status.h
@@ -8,6 +8,10 @@ 
 #ifndef _SWUPDATE_STATUS_H
 #define _SWUPDATE_STATUS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * This is used to send back the result of an update.
  * It is strictly forbidden to change the order of entries.
@@ -33,4 +37,8 @@  typedef enum {
 	SOURCE_LOCAL
 } sourcetype;
 
+#ifdef __cplusplus
+}   // extern "C"
+#endif
+
 #endif