From eec08ac97b757a9b22959dfa5ed97f8724b5d25a Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 1 Jul 2014 17:05:57 +0100 Subject: [PATCH] mraa.c: stop ctor running in scripting languages Signed-off-by: Brendan Le Foll --- api/mraa/common.h | 6 +++--- src/mraa.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/mraa/common.h b/api/mraa/common.h index 1e296d8..ba81339 100644 --- a/api/mraa/common.h +++ b/api/mraa/common.h @@ -177,13 +177,13 @@ typedef struct { * * @return Result of operation */ -#ifndef SWIG +#if (defined SWIGPYTHON) || (defined SWIG) +mraa_result_t mraa_init(); +#else // this sets a compiler attribute (supported by GCC & clang) to have mraa_init() // be called as a constructor make sure your libc supports this! uclibc needs // to be compiled with UCLIBC_CTOR_DTOR mraa_result_t mraa_init() __attribute__((constructor)); -#else -mraa_result_t mraa_init(); #endif /** diff --git a/src/mraa.c b/src/mraa.c index 2da9c47..ee81559 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -45,13 +45,16 @@ mraa_get_version() return gVERSION; } -#ifdef SWIG +#if 0 +const mraa_adv_func* +mraa_get_advance() +{ + return (const mraa_adv_func*) advance; +} +#endif + mraa_result_t mraa_init() -#else -mraa_result_t __attribute__((constructor)) -mraa_init() -#endif { /** Once more board definitions have been added, * A method for detecting them will need to be devised.