Search code examples
cstructcompiler-errorswdk

Porting from Linux to Windows 8: Struct member names


I'm porting some (working) code from Linux to Windows 8. I'm using DDK.

typedef struct {
    unsigned int test1;
    unsigned int test2;
} settings;

const settings vp_settings = {
    .test1 = 1,
    .test2 = 1
};

What is different about the Windows DDK compiler and GCC that makes this invalid? The error I'm getting, assuming typedef struct { is line 1 and numbering continues normally:

(7) : error: C2059: syntax error : '.'

How can I write this in such a way that there will be no syntax errors? I would like to keep the same member names so I don't need to alter the rest of the code base. Is the period superfluous and can be removed?


Solution

  • Q: What's wrong with (vanilla):

    const settings vp_settings = {
        1, /* test1 */
        1  /* test2 */
    };
    

    PS:

    How to rewrite C-struct designated initializers to C89 (resp MSVC C compiler)

    This looks like a C99 thing ... and AFAIK MSVS does not fully support C99...