From 06f580d722136051c55653f6767f185b396f3371 Mon Sep 17 00:00:00 2001 From: "Dr. Orion Lawlor" Date: Mon, 17 Apr 2017 21:38:46 -0800 Subject: Support calling the library from C++, by adding extern "C" decorations, and including correct prototypes. --- include/libsurvive/poser.h | 9 +++++++++ include/libsurvive/survive.h | 13 ++++++++++++- include/libsurvive/survive_types.h | 8 ++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libsurvive/poser.h b/include/libsurvive/poser.h index 497b009..582590e 100644 --- a/include/libsurvive/poser.h +++ b/include/libsurvive/poser.h @@ -3,6 +3,11 @@ #include "survive_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + typedef enum PoserType_t { POSERDATA_NONE = 0, @@ -55,4 +60,8 @@ typedef struct typedef int (*PoserCB)( SurviveObject * so, PoserData * pd ); +#ifdef __cplusplus +}; +#endif + #endif diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h index 278bbca..3c35bd2 100644 --- a/include/libsurvive/survive.h +++ b/include/libsurvive/survive.h @@ -5,6 +5,10 @@ #include "survive_types.h" #include "poser.h" +#ifdef __cplusplus +extern "C" { +#endif + //DANGER: This structure may be redefined. Note that it is logically split into 64-bit chunks //for optimization on 32- and 64-bit systems. @@ -116,7 +120,7 @@ void survive_install_imu_fn( SurviveContext * ctx, imu_process_func fbp ); void survive_install_angle_fn( SurviveContext * ctx, angle_process_func fbp ); void survive_close( SurviveContext * ctx ); -int survive_poll(); +int survive_poll( SurviveContext * ctx ); SurviveObject * survive_get_so_by_name( SurviveContext * ctx, const char * name ); @@ -128,6 +132,9 @@ int survive_send_magic( SurviveContext * ctx, int magic_code, void * data, int d //Install the calibrator. void survive_cal_install( SurviveContext * ctx ); //XXX This will be removed if not already done so. +// Read back a human-readable string description of the calibration status +int survive_cal_get_status( struct SurviveContext * ctx, char * description, int description_length ); + //Call these from your callback if overridden. //Accept higher-level data. void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , uint32_t lh); @@ -174,5 +181,9 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ); #define SV_ERROR( ... ) { char stbuff[1024]; sprintf( stbuff, __VA_ARGS__ ); ctx->faultfunction( ctx, stbuff ); } #define SV_KILL() exit(0) //XXX This should likely be re-defined. +#ifdef __cplusplus +}; +#endif + #endif diff --git a/include/libsurvive/survive_types.h b/include/libsurvive/survive_types.h index bfd0b1d..224719e 100644 --- a/include/libsurvive/survive_types.h +++ b/include/libsurvive/survive_types.h @@ -1,6 +1,11 @@ #ifndef _SURVIVE_TYPES_H #define _SURVIVE_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif + + #ifndef FLT #ifdef USE_DOUBLE #define FLT double @@ -39,6 +44,9 @@ typedef int (*DeviceDriver)( SurviveContext * ctx ); typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver ); typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen ); +#ifdef __cplusplus +}; +#endif #endif -- cgit v1.2.3