Compiler errors in WINNT.H after retargeting solution to latest SDK (10.0.18362)

1.4k views Asked by At

After retargeting my solution to SDK version 10.0 (latest installed version) (10.0.18362) and upgrading my projects to platform toolset v142, I am receving compile-time errors in winnt.h as follows:

...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18611,19): error C2143: syntax error: missing ':' before 'constant'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18611,22): error C2143: syntax error: missing ';' before ':'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18611,22): error C2059: syntax error: ':'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18612,29): error C2143: syntax error: missing '{' before ':'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18612,29): error C2059: syntax error: ':'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18613,9): error C2059: syntax error: '}'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18614,5): error C2059: syntax error: '}'
...\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(18615,1): error C2059: syntax error: '}'

This happens purely as a result of the upgrade. What might I have done wrong?

1

There are 1 answers

0
ladenedge On BEST ANSWER

It turns out I had defined a CR macro in my code like so:

#define CR "\r"

It was overwriting the name of a struct data member in the Windows SDK header.

typedef struct _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY {
    DWORD BeginAddress;
    union {
        DWORD UnwindData;
        struct {
            DWORD Flag : 2;
            DWORD FunctionLength : 11;
            DWORD RegF : 3;
            DWORD RegI : 4;
            DWORD H : 1;
            DWORD CR : 2;           // <-- conflicting member
            DWORD FrameSize : 9;
        } DUMMYSTRUCTNAME;
    } DUMMYUNIONNAME;
} IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY, * PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY;

The same thing happened to this fellow asking for help on the MSFT dev boards.

You'll have to rename your #define or avoid upgrading the SDK.