[babl/wip/msvc] babl: Force USE_ALLOCA for MSVC builds
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl/wip/msvc] babl: Force USE_ALLOCA for MSVC builds
- Date: Mon, 20 Jan 2020 09:57:40 +0000 (UTC)
commit 65ec70f2a4ad492ddff6b280452aafc943ba87f1
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jan 20 16:30:38 2020 +0800
babl: Force USE_ALLOCA for MSVC builds
This is because Visual Studio does not support C99 VLA's, so compensate this by
using alloca() via _alloca()
babl/babl-format.c | 8 ++++++++
meson.build | 2 ++
2 files changed, 10 insertions(+)
---
diff --git a/babl/babl-format.c b/babl/babl-format.c
index 2e4e3d718..4892ed32c 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -260,9 +260,17 @@ babl_format_n (const Babl *btype,
int id = 0;
int planar = 0;
BablModel *model = (BablModel *)babl_model ("Y");
+
+#ifdef USE_ALLOCA
+ BablComponent **component = alloca (sizeof (void *) * components);
+ BablSampling **sampling = alloca (sizeof (void *) * components);
+ const BablType **type = alloca (sizeof (void *) * components);
+#else
BablComponent *component [components];
BablSampling *sampling [components];
const BablType *type [components];
+#endif
+
char *name = NULL;
for (i = 0; i<components; i++)
diff --git a/meson.build b/meson.build
index f20b7f9f0..f5151bc66 100644
--- a/meson.build
+++ b/meson.build
@@ -175,6 +175,8 @@ if cc.get_id() == 'msvc'
msvc_cflags = [
'-utf-8', # Avoid C4819 (Unicode handling) compiler warnings
'-D_USE_MATH_DEFINES', # Allow more math macro usage
+ '-DUSE_ALLOCA', # Use alloca via _alloca()
+ '-Dalloca=_alloca',
'-wd4244', # Silence some unneeded compiler warnings
'-wd4305'
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]