C 和 C++ 混合代码 cmath编译出错

最近在网上下载了 Triangle 库,准备在程序中调用来三角化生成网格,但出现了很多错误,如下:

1>  triangle.c
1>d:\program files\visualstudio2010\vc\include\cmath(19): error C2061: 语法错误: 标识符“acosf”
1>d:\program files\visualstudio2010\vc\include\cmath(19): error C2059: 语法错误:“;”
1>d:\program files\visualstudio2010\vc\include\cmath(19): error C2061: 语法错误: 标识符“asinf”
1>d:\program files\visualstudio2010\vc\include\cmath(19): error C2059: 语法错误:“;”
1>d:\program files\visualstudio2010\vc\include\cmath(20): error C2061: 语法错误: 标识符“atanf”
1>d:\program files\visualstudio2010\vc\include\cmath(20): error C2059: 语法错误:“;”
1>d:\program files\visualstudio2010\vc\include\cmath(20): error C2061: 语法错误: 标识符“atan2f”
1>d:\program files\visualstudio2010\vc\include\cmath(20): error C2059: 语法错误:“;”

………..

由于我使用的是VS2010,用 C++ 写的程序,而Triangle库是用 C 语言写的,问题可能出在这。百度下这个错误,在自古英雄谁无泪的博客中找到了解决办法,更多请参考歆悰的博文和stackoverflow的ms vc++ iostream compile error

项目 ––> 属性 ––> 配置属性 ––> C/C++ ––> 高级 ––> 编译为 ––> 编译为C++代码

 

另外该博文的原作歆悰的心得很有道理,故放在这里同时告诫自己!

心得:

所有跟C++相关的语句均报错,应该能够想得到是环境的问题,不善于思考了,唉。

代码没问题,肯定是环境的问题。

搜索英文的解决方案比较靠谱和专业,中文的回复太多垃圾。

posted @ 2015-07-23 12:56  VVingerfly  阅读(1675)  评论(0编辑  收藏  举报