c++cvisual-studiocompiler-errors

"Triangle" with VS2012?


There is a triangular mesh generator (Shewchuk, CMU), "Triangle", that are recommended by people due to its lightweight. It is written in C. However I cannot use it in my VS2012 C++ project. I am compiling it using x64 platform. I am on Windows 7 64-bit.

Basically, I compile the triangle.c as the makefile described. So, a triangle.o is generated. I then

  1. added triangle.o as additional dependencies in my solution,
  2. added triangle.c and triangle.h in my project .
  3. changed triangle.c in C/C++ precompiled header option, to "not using precompiled header"

Then I got tons of errors like this:

1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(430): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(430): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(497): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(497): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(498): error C2143: syntax error : missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(498): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(2517): warning C4391: 'SHORT _InterlockedIncrement16(volatile SHORT *)' : incorrect return type for intrinsic function, expected 'short'

I am just wondering, is there anyway to make the triangular mesh generator work with VS2012 C++ project? If so, what is the right way to set it up on VS2012 C++ x64?


Solution

  • You might want to have a look at this: Compilation errors of a simple C++ project in VS 2012.RC 4 disable pre-compiled headers, and delete the pch file from the intermediate directory.

    This initially didn't work for me, so I tried moving #include at the top of the file, before all other includes, and this worked for me.