Skip to content
Snippets Groups Projects
Commit e49247bf authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Make compatible with MSVC

parent 39389246
No related branches found
No related tags found
No related merge requests found
Pipeline #2638 passed
......@@ -2,20 +2,20 @@ project('stdlib', 'c',
default_options: ['warning_level=3', 'c_std=gnu99'])
cc = meson.get_compiler('c')
libm = cc.find_library('m')
libm = cc.find_library('m', required: false)
glib_dep = dependency('glib-2.0', version: '>= 2.16', required: false)
openmp_dep = dependency('openmp', required: false)
thread_dep = dependency('threads', required: false)
pthreads_dep = dependency('pthreads', required: false)
conf_data = configuration_data()
cc = meson.get_compiler('c')
has_reallocarray = cc.has_function('reallocarray')
if cc.has_function('reallocarray')
conf_data.set('HAVE_REALLOCARRAY', 1)
endif
has_strndup = cc.has_function('strndup')
configure_file(configuration: conf_data, output: 'config.h')
config_dep = declare_dependency(include_directories: '.')
......@@ -29,6 +29,6 @@ endif
subdir('lib')
subdir('src')
if glib_dep.found()
if glib_dep.found() and cc.get_id() != 'msvc'
subdir('test')
endif
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include <stdio.h>
#include <tgmath.h>
......
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>
#define ACC 1e-9
......
......@@ -12,7 +12,7 @@ add_data (SList *list)
printf ("Input the data ");
scanf ("%s", buffer);
char *str = strdup (buffer);
char *str = strndup (buffer, sizeof (buffer));
return slist_prepend (list, str);
}
......
......@@ -3,7 +3,6 @@ executable('angle', 'angle.c', dependencies: libm)
executable('array-length', 'array-length.c', dependencies: types_dep)
executable('binary', 'binary.c')
executable('binary2', 'binary2.c', dependencies: utils_dep)
executable('complex', 'complex.c', dependencies: libm)
executable('doubles', 'doubles.c')
executable('einstein', 'einstein.c')
executable('fib', 'fib.c')
......@@ -12,24 +11,31 @@ executable('fixed-sizeof', 'fixed-sizeof.c')
executable('fgets', 'fgets.c')
executable('gcd', 'gcd.c')
executable('getchar', 'getchar.c')
executable('hashtable-test', 'hashtable-test.c', dependencies: types_dep)
executable('kepler', 'kepler.c', dependencies: libm)
executable('list-test', 'list-test.c', dependencies: types_dep)
executable('next', 'next.c', dependencies: libm)
executable('parrot', 'parrot.c')
executable('sizeof', 'sizeof.c')
executable('snprintf', 'snprintf.c')
executable('strtol', 'strtol.c')
executable('taylor', 'taylor.c')
executable('winter', 'winter.c')
executable('world', 'world.c')
if has_strndup
executable('hashtable-test', 'hashtable-test.c', dependencies: types_dep)
executable('list-test', 'list-test.c', dependencies: types_dep)
endif
if cc.get_id() != 'msvc'
executable('complex', 'complex.c', dependencies: libm)
executable('parrot', 'parrot.c')
executable('strtol', 'strtol.c')
endif
subdir('sockets')
if openmp_dep.found()
subdir('openmp')
endif
if thread_dep.found()
if pthreads_dep.found()
subdir('pthread')
endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <tgmath.h>
int
main (int argc, char **argv)
......@@ -27,7 +27,7 @@ main (int argc, char **argv)
do
{
current = nextafter (current, end);
current = nextafterf (current, end);
count++;
} while (current != end);
......
executable('pi', 'pi.c', dependencies: [openmp_dep, libm])
executable('simd', 'simd.c', dependencies: openmp_dep)
executable('taylor', 'taylor.c', dependencies: openmp_dep)
executable('threads', 'threads.c', dependencies: openmp_dep)
if cc.get_id() != 'msvc'
executable('pi', 'pi.c', dependencies: [openmp_dep, libm])
executable('simd', 'simd.c', dependencies: openmp_dep)
executable('taylor', 'taylor.c', dependencies: openmp_dep)
endif
executable('thread-incr', 'thread-incr.c',
dependencies: [thread_dep, utils_dep])
dependencies: [pthreads_dep, utils_dep])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment