最近一个项目中,需要用MFC调用C源程序,经过查找和实验。具体做法如下:
1.C程序文件文件名必须改为*.cpp;
2.C程序中提供给其它类(别的*.cpp文件)调用的函数必须在*.h文件中声明;
3. 在*.h文件和*.cpp(调用的C程序)文件的开头第一行(必须、除注释)加上 #include "stdafx.h",否则会提示
fatal error C1010: unexpected end of file while looking for precompiled header directive
4.如果还有错误试试下面的设置:
<1>.设置对c文件不使用预编译,project setting -> c/c++ -> category -> precompiled headers -> not using precompiled headers
<2>.包含头时使用 extern "c"
前3步在VC6.0下测试成功;第四步是网上看到的,没有实验,写在这里只是提供解决问题的方法。