diff options
author | David Robillard <d@drobilla.net> | 2012-08-03 16:43:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-03 16:43:57 +0000 |
commit | 769d980f5ef68b84b8a4fe016eccced4d3b06b49 (patch) | |
tree | e697e4aa125a1fbfae858f5ae681721305cb8ae4 | |
parent | 6d856f2c3207fd5acd513d41f72830c29daf07f2 (diff) | |
download | suil-769d980f5ef68b84b8a4fe016eccced4d3b06b49.tar.gz suil-769d980f5ef68b84b8a4fe016eccced4d3b06b49.tar.bz2 suil-769d980f5ef68b84b8a4fe016eccced4d3b06b49.zip |
Fix compilation with MSVC.
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@4609 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/host.c | 2 | ||||
-rw-r--r-- | src/instance.c | 4 | ||||
-rw-r--r-- | src/suil_internal.h | 7 | ||||
-rw-r--r-- | suil/suil.h | 3 | ||||
-rw-r--r-- | wscript | 30 |
5 files changed, 29 insertions, 17 deletions
@@ -23,7 +23,7 @@ suil_host_new(SuilPortWriteFunc write_func, SuilPortSubscribeFunc subscribe_func, SuilPortUnsubscribeFunc unsubscribe_func) { - SuilHost* host = malloc(sizeof(struct SuilHostImpl)); + SuilHost* host = (SuilHost*)malloc(sizeof(struct SuilHostImpl)); host->write_func = write_func; host->index_func = index_func; host->subscribe_func = subscribe_func; diff --git a/src/instance.c b/src/instance.c index 0f9434a..617280e 100644 --- a/src/instance.c +++ b/src/instance.c @@ -98,7 +98,7 @@ open_wrapper(SuilHost* host, + strlen(module_name) + 2; - char* const path = calloc(path_len, 1); + char* const path = (char*)calloc(path_len, 1); snprintf(path, path_len, "%s%s%s%s%s", mod_dir, SUIL_DIR_SEP, SUIL_MODULE_PREFIX, module_name, SUIL_MODULE_EXT); @@ -184,7 +184,7 @@ suil_instance_new(SuilHost* host, } // Create SuilInstance - SuilInstance* instance = calloc(1, sizeof(struct SuilInstanceImpl)); + SuilInstance* instance = (SuilInstance*)calloc(1, sizeof(SuilInstance)); if (!instance) { SUIL_ERRORF("Failed to allocate memory for <%s> instance\n", ui_uri); dlclose(lib); diff --git a/src/suil_internal.h b/src/suil_internal.h index 385dc26..0e565cb 100644 --- a/src/suil_internal.h +++ b/src/suil_internal.h @@ -24,8 +24,10 @@ #ifdef _WIN32 #include <windows.h> #define dlopen(path, flags) LoadLibrary(path) -#define dlclose(lib) FreeLibrary(lib) +#define dlclose(lib) FreeLibrary((HMODULE)lib) #define dlsym GetProcAddress +#define inline __inline +#define snprintf _snprintf static inline char* dlerror(void) { return "Unknown error"; } #else #include <dlfcn.h> @@ -35,8 +37,7 @@ static inline char* dlerror(void) { return "Unknown error"; } #include "suil/suil.h" -#define SUIL_ERRORF(fmt, ...) fprintf(stderr, "error: %s: " fmt, \ - __func__, __VA_ARGS__) +#define SUIL_ERRORF(fmt, ...) fprintf(stderr, "suil error: " fmt, __VA_ARGS__) struct SuilHostImpl { SuilPortWriteFunc write_func; diff --git a/suil/suil.h b/suil/suil.h index ae228c4..b9adbef 100644 --- a/suil/suil.h +++ b/suil/suil.h @@ -21,7 +21,6 @@ #ifndef SUIL_SUIL_H #define SUIL_SUIL_H -#include <stdbool.h> #include <stdint.h> #include "lv2/lv2plug.in/ns/lv2core/lv2.h" @@ -45,6 +44,8 @@ #ifdef __cplusplus extern "C" { +#else +# include <stdbool.h> #endif /** @@ -40,7 +40,15 @@ def configure(conf): autowaf.configure(conf) autowaf.display_header('Suil Configuration') - conf.env.append_unique('CFLAGS', '-std=c99') + conf.env['NODELETE_FLAGS'] = [] + if conf.env['MSVC_COMPILER']: + conf.env.append_unique('CFLAGS', ['-TP', '-MD']) + else: + conf.env.append_unique('CFLAGS', '-std=c99') + if conf.check(linkflags = ['-Wl,-z,nodelete'], + msg = 'Checking for link flags -Wl,-z,-nodelete', + mandatory = False): + conf.env['NODELETE_FLAGS'] = ['-Wl,-z,nodelete'] autowaf.check_pkg(conf, 'lv2', atleast_version='1.0.0', uselib_store='LV2') @@ -58,12 +66,6 @@ def configure(conf): autowaf.check_pkg(conf, 'QtGui', uselib_store='QT4', atleast_version='4.0.0', mandatory=False) - conf.env['NODELETE_FLAGS'] = [] - if conf.check(linkflags = ['-Wl,-z,nodelete'], - msg = 'Checking for link flags -Wl,-z,-nodelete', - mandatory = False): - conf.env['NODELETE_FLAGS'] = ['-Wl,-z,nodelete'] - autowaf.define(conf, 'SUIL_VERSION', SUIL_VERSION) autowaf.define(conf, 'SUIL_MODULE_DIR', conf.env['LIBDIR'] + '/suil-' + SUIL_MAJOR_VERSION) @@ -99,7 +101,10 @@ def build(bld): cflags = [] lib = [] - if sys.platform != 'win32': + modlib = [] + if sys.platform == 'win32': + modlib += ['user32'] + else: cflags += ['-fvisibility=hidden'] lib += ['dl'] @@ -126,7 +131,8 @@ def build(bld): includes = ['.'], defines = ['SUIL_SHARED', 'SUIL_INTERNAL'], install_path = module_dir, - cflags = cflags) + cflags = cflags, + lib = modlib) autowaf.use_lib(bld, obj, 'GTK2 QT4 LV2') obj = bld(features = 'cxx cxxshlib', @@ -136,6 +142,7 @@ def build(bld): defines = ['SUIL_SHARED', 'SUIL_INTERNAL'], install_path = module_dir, cflags = cflags, + lib = modlib, linkflags = bld.env['NODELETE_FLAGS']) autowaf.use_lib(bld, obj, 'GTK2 QT4 LV2') @@ -147,6 +154,7 @@ def build(bld): defines = ['SUIL_SHARED', 'SUIL_INTERNAL'], install_path = module_dir, cflags = cflags, + lib = modlib, linkflags = bld.env['NODELETE_FLAGS']) autowaf.use_lib(bld, obj, 'GTK2 GTK2_X11 LV2') @@ -158,6 +166,7 @@ def build(bld): defines = ['SUIL_SHARED', 'SUIL_INTERNAL'], install_path = module_dir, cflags = cflags, + lib = modlib, linkflags = bld.env['NODELETE_FLAGS']) autowaf.use_lib(bld, obj, 'GTK2 LV2') @@ -168,7 +177,8 @@ def build(bld): includes = ['.'], defines = ['SUIL_SHARED', 'SUIL_INTERNAL'], install_path = module_dir, - cflags = cflags) + cflags = cflags, + lib = modlib) autowaf.use_lib(bld, obj, 'QT4 LV2') # Documentation |