Message ID | CAGssATgzeWHBzWREQXBtgALNp8wveDUw1FuJsKkYebZw-N2Dwg@mail.gmail.com |
---|---|
State | Changes Requested |
Headers | show |
Series | Add cpp guards in IPC interface | expand |
On 30/07/19 17:08, 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. Yes, it is. > > Signed-off-by: Guy Morand <g.morand@scewo.ch> > --- > include/network_ipc.h | 8 ++++++++ > include/progress_ipc.h | 9 +++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/include/network_ipc.h b/include/network_ipc.h > index e41493c..6fd7052 100644 > --- a/include/network_ipc.h > +++ b/include/network_ipc.h > @@ -9,6 +9,10 @@ > #ifndef _IPC_H > #define _IPC_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 > @@ -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..b895162 100644 > --- a/include/progress_ipc.h > +++ b/include/progress_ipc.h > @@ -8,6 +8,10 @@ > #ifndef _PROGRESS_IPC_H > #define _PROGRESS_IPC_H > > +#ifdef __cplusplus > +extern "C" { > +#endif > + > #include <stdbool.h> > #include <swupdate_status.h> > > @@ -44,4 +48,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 > Acked-by: Stefanop Babic <sbabic@denx.de> Best regards, Stefano Babic
On 31/07/19 12:03, Stefano Babic wrote: > On 30/07/19 17:08, 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. > > Yes, it is. > >> >> Signed-off-by: Guy Morand <g.morand@scewo.ch> >> --- >> include/network_ipc.h | 8 ++++++++ >> include/progress_ipc.h | 9 +++++++++ >> 2 files changed, 17 insertions(+) >> >> diff --git a/include/network_ipc.h b/include/network_ipc.h >> index e41493c..6fd7052 100644 >> --- a/include/network_ipc.h >> +++ b/include/network_ipc.h >> @@ -9,6 +9,10 @@ >> #ifndef _IPC_H >> #define _IPC_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 >> @@ -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..b895162 100644 >> --- a/include/progress_ipc.h >> +++ b/include/progress_ipc.h >> @@ -8,6 +8,10 @@ >> #ifndef _PROGRESS_IPC_H >> #define _PROGRESS_IPC_H >> >> +#ifdef __cplusplus >> +extern "C" { >> +#endif >> + >> #include <stdbool.h> >> #include <swupdate_status.h> >> >> @@ -44,4 +48,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 >> > > Acked-by: Stefanop Babic <sbabic@denx.de> > Your patch is malformed - I get errors when I try to apply it: patching file include/network_ipc.h Hunk #2 succeeded at 82 with fuzz 2. patching file include/progress_ipc.h patch: **** malformed patch at line 216: *socketpath, bool reconnect); Please rebase and resend (with git send-email). Best regards, Stefano Babic
diff --git a/include/network_ipc.h b/include/network_ipc.h index e41493c..6fd7052 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -9,6 +9,10 @@ #ifndef _IPC_H #define _IPC_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 @@ -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..b895162 100644 --- a/include/progress_ipc.h +++ b/include/progress_ipc.h @@ -8,6 +8,10 @@ #ifndef _PROGRESS_IPC_H #define _PROGRESS_IPC_H +#ifdef __cplusplus +extern "C" { +#endif + #include <stdbool.h> #include <swupdate_status.h> @@ -44,4 +48,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 +
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 | 8 ++++++++ include/progress_ipc.h | 9 +++++++++ 2 files changed, 17 insertions(+) #endif