After having converted a project from Visual Studio 2005 to Visual Studio 2010, it appears the project doesn’t build anymore and spits out tons of C2059 errors like:
`error C2059: syntax error : ‘type’
We’re using Visual Studio 2010 Professional which doesn’t provide static code analysis.
Here is the full log for the compilation of 1 C file for reference:
1>------ Build started: Project: VoHR, Configuration: Debug Win32 ------
1> AKAsynch.c
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(88): error C2059: syntax error : 'type'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(107): error C2059: syntax error : '}'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(119): error C2059: syntax error : 'type'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(139): error C2059: syntax error : '}'
I tracked down the reason of those sudden compiler errors.
In the great tradition of
windows.hit appears that Microsoft introduced tokens that cause name clashes with our codebase.In our precise case, we had:
#define Null (void*)0Somewhere in our code, we need to use the
offsetofmacro and to make it available we#include <stddef.h>I tracked down
stddef.hin turns includescrtdefs.hwhich ends up includingsal.hwhere ourNullmacro seems to clash with source code annotation in MS headers…As a workaround, we did:
Our use of
Nullas a macro is arguable, still I would have expected MS to find a way to avoid clashes with existing code bases.Hope that helps those facing the same issue.