Troublesome C99 ?

Submitted by Antonio Ospite on Dec. 8, 2017, 9:02 a.m.

Details

Message ID 20171208100257.673c80706537ebf54c5c36b4@ao2.it
State New
Series "Troublesome C99 ?"
Headers show

Commit Message

Antonio Ospite Dec. 8, 2017, 9:02 a.m.
On Tue, 05 Dec 2017 10:51:50 +0000
John Emmas <john@creativepost.co.uk> wrote:

> Hi there,
> 
> This morning I noticed this change in git master (which produces a 
> syntax error now when compiling with MSVC):-
> 
[...]
> // In 'src/cairo-svg-surface.c' :-
>      static const char * _cairo_svg_unit_strings[] =
>      {
>          [CAIRO_SVG_UNIT_USER] = "",  // <--- error occurs here !!
[...]
> 
> I think it's ( possibly? ) C99, which MSVC never fully supported :-(
> 

This was me, I assumed using C99 initializers was OK.
If it's not then the attached patch fixes this.

Should I send it over to bugzilla?

BTW when compilation fails it is generally a good idea to report the
exact message from the compiler.

Ciao,
   Antonio

Patch hide | download patch | download mbox

From 815685bc0a7432788d55dbe45e18c99f44a26f6f Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ao2@ao2.it>
Date: Fri, 8 Dec 2017 09:44:27 +0100
Subject: [PATCH] svg: fix compilation with MSVC which doesn't support C99
 initializers
X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM<pyWR#k60!#=#>/Vb;]yA5<GWI5`6u&+
 ;6b'@y|8w"wB;4/e!7wYYrcqdJFY,~%Gk_4]cq$Ei/7<j&N3ah(m`ku?pX.&+~:_/wC~dwn^)MizBG
 !pE^+iDQQ1yC6^,)YDKkxDd!T>\I~93>J<_`<4)A{':UrE

---
 src/cairo-svg-surface.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 1b568542e..c2ef83efa 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -124,16 +124,16 @@  static const char * _cairo_svg_internal_version_strings[CAIRO_SVG_VERSION_LAST]
 
 static const char * _cairo_svg_unit_strings[] =
 {
-    [CAIRO_SVG_UNIT_USER] = "",
-    [CAIRO_SVG_UNIT_EM] = "em",
-    [CAIRO_SVG_UNIT_EX] = "ex",
-    [CAIRO_SVG_UNIT_PX] = "px",
-    [CAIRO_SVG_UNIT_IN] = "in",
-    [CAIRO_SVG_UNIT_CM] = "cm",
-    [CAIRO_SVG_UNIT_MM] = "mm",
-    [CAIRO_SVG_UNIT_PT] = "pt",
-    [CAIRO_SVG_UNIT_PC] = "pc",
-    [CAIRO_SVG_UNIT_PERCENT] = "%"
+    "",
+    "em",
+    "ex",
+    "px",
+    "in",
+    "cm",
+    "mm",
+    "pt",
+    "pc",
+    "%"
 };
 
 struct cairo_svg_page {
-- 
2.15.1


Comments

John Emmas Dec. 8, 2017, 9:28 a.m.
On 08/12/2017 09:02, Antonio Ospite wrote:
>
> This was me, I assumed using C99 initializers was OK.
> If it's not then the attached patch fixes this.
>
> Should I send it over to bugzilla?
>
> BTW when compilation fails it is generally a good idea to report the
> exact message from the compiler.
>

Hi Antonio.  I normally do report the errors but in this case it was 
simply:- "error C2059: syntax error : '[' ".

Your patch works fine BTW.  Many thanks,

John
Bryce Harrington Dec. 11, 2017, 4:22 a.m.
On Fri, Dec 08, 2017 at 09:28:47AM +0000, John Emmas wrote:
> On 08/12/2017 09:02, Antonio Ospite wrote:
> >
> >This was me, I assumed using C99 initializers was OK.
> >If it's not then the attached patch fixes this.
> >
> >Should I send it over to bugzilla?
> >
> >BTW when compilation fails it is generally a good idea to report the
> >exact message from the compiler.
> >
> 
> Hi Antonio.  I normally do report the errors but in this case it was
> simply:- "error C2059: syntax error : '[' ".
> 
> Your patch works fine BTW.  Many thanks,

Thanks, pushed:

To ssh://git.freedesktop.org/git/cairo
   f9cf6f9..19ee921  master -> master



commit 19ee9211879ad8c90ee7d467d8d9495dc9a0fa88
Author:     Antonio Ospite <ao2@ao2.it>
AuthorDate: Fri Dec 8 09:44:27 2017 +0100
Commit:     Bryce Harrington <bryce@osg.samsung.com>
CommitDate: Sun Dec 10 20:13:19 2017 -0800

    svg: fix compilation with MSVC which doesn't support C99
    initializers

    Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
    Tested-by: John Emmas <john@creativepost.co.uk>