From 72121bc7d88bbd6577cd3ea88b301d91ac35d675 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 10 May 2019 21:16:10 +0300 Subject: [PATCH] sanei: Use C linkage for internal functions in C++ mode --- backend/stubs.c | 8 ++++++++ include/sane/sanei.h | 7 +++++++ include/sane/sanei_backend.h | 8 ++++++++ include/sane/sanei_config.h | 8 ++++++++ include/sane/sanei_debug.h | 8 ++++++++ include/sane/sanei_magic.h | 8 ++++++++ include/sane/sanei_usb.h | 8 ++++++++ 7 files changed, 55 insertions(+) diff --git a/backend/stubs.c b/backend/stubs.c index 3fb5ce3d6..a8afd3e4e 100644 --- a/backend/stubs.c +++ b/backend/stubs.c @@ -5,6 +5,10 @@ /* Now define the wrappers (we could use aliases here, but go for robustness for now...: */ +#ifdef __cplusplus +extern "C" { +#endif + SANE_Status sane_init (SANE_Int *vc, SANE_Auth_Callback cb) { @@ -83,3 +87,7 @@ sane_exit (void) { ENTRY(exit) (); } + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/include/sane/sanei.h b/include/sane/sanei.h index 4ff765d74..aa7003ad1 100644 --- a/include/sane/sanei.h +++ b/include/sane/sanei.h @@ -89,6 +89,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** @name Public macros and functions * @{ */ @@ -167,5 +171,8 @@ extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value, SANE_Word * info); +#ifdef __cplusplus +} // extern "C" +#endif #endif /* sanei_h */ diff --git a/include/sane/sanei_backend.h b/include/sane/sanei_backend.h index 89e2edb64..32d8ce0c8 100644 --- a/include/sane/sanei_backend.h +++ b/include/sane/sanei_backend.h @@ -113,6 +113,10 @@ /** @name Declaration of entry points: * @{ */ +#ifdef __cplusplus +extern "C" { +#endif + extern SANE_Status ENTRY(init) (SANE_Int *, SANE_Auth_Callback); extern SANE_Status ENTRY(get_devices) (const SANE_Device ***, SANE_Bool); extern SANE_Status ENTRY(open) (SANE_String_Const, SANE_Handle *); @@ -130,6 +134,10 @@ extern void ENTRY(cancel) (SANE_Handle); extern void ENTRY(close) (SANE_Handle); extern void ENTRY(exit) (void); +#ifdef __cplusplus +} // extern "C" +#endif + #ifndef STUBS /* Now redirect sane_* calls to backend's functions: */ diff --git a/include/sane/sanei_config.h b/include/sane/sanei_config.h index f81bdd49f..3a6016736 100644 --- a/include/sane/sanei_config.h +++ b/include/sane/sanei_config.h @@ -52,6 +52,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /** Search configuration file \a name along directory list and return file * pointer if such a file exists. * @@ -172,4 +176,8 @@ extern SANE_Status sanei_configure_attach ( */ extern const char *sanei_config_get_paths (void); +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* sanei_config_h */ diff --git a/include/sane/sanei_debug.h b/include/sane/sanei_debug.h index 5198af400..465d3e25e 100644 --- a/include/sane/sanei_debug.h +++ b/include/sane/sanei_debug.h @@ -9,6 +9,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /** @name Public macros * These macros can be used in backends and other SANE-related * code. @@ -150,4 +154,8 @@ extern void sanei_init_debug (const char * backend, int * debug_level_var); #endif /* NDEBUG */ +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* _SANEI_DEBUG_H */ diff --git a/include/sane/sanei_magic.h b/include/sane/sanei_magic.h index ba6a43286..297becdfc 100644 --- a/include/sane/sanei_magic.h +++ b/include/sane/sanei_magic.h @@ -57,6 +57,10 @@ #ifndef SANEI_MAGIC_H #define SANEI_MAGIC_H +#ifdef __cplusplus +extern "C" { +#endif + /** Initialize sanei_magic. * * Call this before any other sanei_magic function. @@ -219,4 +223,8 @@ extern SANE_Status sanei_magic_turn(SANE_Parameters * params, SANE_Byte * buffer, int angle); +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* SANEI_MAGIC_H */ diff --git a/include/sane/sanei_usb.h b/include/sane/sanei_usb.h index c8fff97a4..ce389cad5 100644 --- a/include/sane/sanei_usb.h +++ b/include/sane/sanei_usb.h @@ -68,6 +68,10 @@ #include /* for size_t */ +#ifdef __cplusplus +extern "C" { +#endif + /* USB spec defines */ #ifndef USB_CLASS_PER_INTERFACE /* Also defined in libusb */ @@ -521,5 +525,9 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate); extern SANE_Status sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ); +#ifdef __cplusplus +} // extern "C" +#endif + /*------------------------------------------------------*/ #endif /* sanei_usb_h */