diff --git a/platform-independent/c/core/build.gradle b/platform-independent/c/core/build.gradle index 8b099340..e20a9a85 100644 --- a/platform-independent/c/core/build.gradle +++ b/platform-independent/c/core/build.gradle @@ -74,7 +74,7 @@ library { link.linkerArgs = ['-lc', '-nodefaultlibs', '-flto'] } else if (toolChain in VisualCpp) { // TODO: Should this be shared instead of static? - compile.compilerArgs = ['/TC', '/MT', '/Ox', '/DSODIUM_STATIC', '/DSODIUM_EXPORT='] + compile.compilerArgs = ['/TC', '/MT', '/Ox', '/DSODIUM_STATIC', '/DSODIUM_EXPORT=', '/std:c11'] } } } diff --git a/platform-independent/c/core/src/mpw-marshal.c b/platform-independent/c/core/src/mpw-marshal.c index 51cab03b..c2a9315f 100644 --- a/platform-independent/c/core/src/mpw-marshal.c +++ b/platform-independent/c/core/src/mpw-marshal.c @@ -250,7 +250,7 @@ void mpw_marshal_file_free( MPMarshalledData *mpw_marshal_data_new() { MPMarshalledData *data = malloc( sizeof( MPMarshalledData ) ); - *data = (MPMarshalledData){}; + *data = (MPMarshalledData){ 0 }; mpw_marshal_data_set_null( data, NULL ); data->is_null = false; return data; diff --git a/platform-independent/c/core/src/mpw-util.c b/platform-independent/c/core/src/mpw-util.c index 4d265cbe..8438236f 100644 --- a/platform-independent/c/core/src/mpw-util.c +++ b/platform-independent/c/core/src/mpw-util.c @@ -22,7 +22,6 @@ MP_LIBS_BEGIN #include #include #include -#include #if MPW_CPERCIVA #include diff --git a/platform-independent/c/core/src/mpw-util.h b/platform-independent/c/core/src/mpw-util.h index 2e9fd23b..159774e2 100644 --- a/platform-independent/c/core/src/mpw-util.h +++ b/platform-independent/c/core/src/mpw-util.h @@ -86,6 +86,21 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct //// Utilities +#ifndef OK +#define OK 0 +#endif +#ifndef ERR +#define ERR -1 +#endif + +#ifndef stringify +#define stringify(s) #s +#endif +#ifndef stringify_def +#define stringify_def(s) stringify(s) +#endif + +#if !__STRICT_ANSI__ && __GNUC__ >= 3 #ifndef min #define min(a, b) ({ \ __typeof__ (a) _a = (a); \ @@ -98,21 +113,18 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) #endif -#ifndef ERR -#define ERR -1 +#define mpw_default(__default, __value) ({ __typeof__ (__value) _v = (__value); _v? _v: (__default); }) +#define mpw_default_n(__default, __num) ({ __typeof__ (__num) _n = (__num); !isnan( _n )? (__typeof__ (__default))_n: (__default); }) +#else +#ifndef min +#define min(a, b) ( (a) < (b) ? (a) : (b) ) #endif -#ifndef OK -#define OK 0 +#ifndef max +#define max(a, b) ( (a) > (b) ? (a) : (b) ) #endif -#ifndef stringify -#define stringify(s) #s +#define mpw_default(__default, __value) ( (__value)? (__value): (__default) ) +#define mpw_default_n(__default, __num) ( !isnan( (__num) )? (__num): (__default) ) #endif -#ifndef stringify_def -#define stringify_def(s) stringify(s) -#endif - -#define mpw_default(__default, __value) ({ __typeof__ (__value) _v = __value; _v? _v: __default; }) -#define mpw_default_n(__default, __num) ({ __typeof__ (__num) _n = (__num); !isnan( _n )? (__typeof__ (__default))_n: __default; }) //// Buffers and memory.