[waffle] [PATCH] wflinfo: Fix MSVC compilation error.

Emil Velikov emil.l.velikov at gmail.com
Fri Jan 30 14:21:46 PST 2015

On 30/01/15 20:02, Jose Fonseca wrote:
> On 30/01/15 16:25, Emil Velikov wrote:
>> On 30 January 2015 at 11:07, Jose Fonseca <jfonseca at vmware.com> wrote:
>>> Workaround what seems to be a bug in MSVC parser for C99.
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_archives_waffle_2015-2DJanuary_000975.html&d=AwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=EOTSIhn-7yCkuKuQ-JCDhS7EtrWFaozBDxo228XaWso&s=0Bi5_OB7Grl7-w1RO8R0l0YtCyi9IkRu-lB9Jtt7Ono&e=
>> Should have spotted this a Frank sent out the patch. Sorry about this
>> Jose.
>> Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
>> Wondering if we should (as a follow up commit) move the variable
>> declarations prior to the code to avoid such fun in the future ?
> It's hard to say.
> It looks like MSVC allows declarations in the middle of blocks, but the
> parser gets into a wierd state some times.
>From my earlier experience this issue happens as the variable type is a
typedef or a struct. For simple types such as int, float, etc. I've not
seen such problems. Or was it when the declaration is initialised
(with/wo a designated initializer) ?

> I think the surer way long term would be to report the MSVC bug to
> Microsoft.  There have been positive experiences in the past [1] [2]
Good point. I'll put it on my list but I don't even have an live/msdn
account :\ I'm not sure when I'll get around to creating one, so if
anyone is interested the following mock-up should be able to visualise
the problem(s).

#include <stdio.h>
#include <stdlib.h>

struct foo {
   int i;

typedef int bar;

   struct foo foo1 = { .i = 1 };
   printf("foo1 %d\n", foo1.i);
// ^^
// The preprocessor/compiler will throw an error here.

   struct foo foo2 = { .i = 2 };
   printf("foo2 %d\n", foo2.i);
// ^^
// The preprocessor/compiler will throw an error here.

   bar bar1 = 1;
   printf("bar1 %d\n", bar1);

   return 0;


More information about the waffle mailing list