3

I have simple console application that was part of another solution. I decided to have this application separately in new solution. After I have opened this application and saved in newly created solution I have following errors:

Error   9   error C2059: syntax error : ')' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12984
Error   4   error C2065: 'PCONTEXT' : undeclared identifier c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12983
Error   10  error C2143: syntax error : missing ';' before '__stdcall'  c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 13372
Error   5   error C2146: syntax error : missing ')' before identifier 'ContextRecord'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12984
Error   1   error C2146: syntax error : missing ';' before identifier 'ContextRecord'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 6361
Error   7   error C2182: 'RtlCaptureContext' : illegal use of type 'void'   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12984
Error   8   error C2491: 'RtlCaptureContext' : definition of dllimport data not allowed c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12984
Error   13  error C3861: '__readfsdword': identifier not found  c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 14982
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 6361
Error   3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 6361
Error   11  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 13372
Error   12  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 13376
    14  IntelliSense: identifier "PCONTEXT" is undefined    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 6361
    15  IntelliSense: identifier "PCONTEXT" is undefined    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12983
    16  IntelliSense: identifier "PCONTEXT" is undefined    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 13371
Warning 6   warning C4229: anachronism used : modifiers on data are ignored c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winnt.h 12984

It's much more easily for me to create new console application than find what is wrong in that situation, but to get more experience I decided to find what is wrong. I have compared C/C++ and Linker settings of both of these applications (newly creatded compiling app and one with errors) and found no differences between them. Where might be problem and what is the way of slowing such problems?

vico
  • 17,051
  • 45
  • 159
  • 315
  • Use instead of Also #define WIN32_LEAN_AND_MEAN before including – cup Aug 15 '14 at 12:30
  • 1
    I'm not using , maybe some vs include are using it. And why newly created project wit the same code and includes builds fine. – vico Aug 15 '14 at 13:13
  • Whait is in the additional includes in the failing project? Have you tried compiling the failing project with C++/Advanced/ShowIncludes switched on? Try that on the working and non working projects. They should both be looking at the same paths but they're probably not. – cup Aug 15 '14 at 16:59
  • Might also be related to other defines like _X86_=1 which clashes with x64. – gast128 Jun 03 '22 at 12:55

1 Answers1

1

If anyone finds this through Google like me: For CLI/C++ projects, make sure any unmanaged .cpp files you are including are set to compile with No CLR support. See below link with answer from Hans Passant.

This fixed this issue for me.

C++ CLI Correct way to use #pragma managed / unmanaged

Nabeel
  • 47
  • 4