Environment
- Win10
- Visual C++ 6.0
Main()
Main-问题1
错误代码
--------------------Configuration: fundation - Win32 Debug--------------------
Compiling...
var.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/fundation.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
fundation.exe - 1 error(s), 0 warning(s)
一个项目中没有main()函数
问题2
错误代码
--------------------Configuration: fundation - Win32 Debug--------------------
Compiling...
var.cpp
add.cpp
Linking...
add.obj : error LNK2005: "int __cdecl add(void)" (?add@@YAHXZ) already defined in var.obj
Debug/fundation.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
fundation.exe - 1 error(s), 0 warning(s)
问题分析:
编译和链接var.cpp & add.cpp时发现add.obj中的int add()已经在var.obj中定义了。
问题3
错误代码
--------------------Configuration: pointer_calculate - Win32 Debug--------------------
Compiling...
pointer_calculate.cpp
d:\wdata\development\workspacc\pointer_calculate\pointer_calculate.cpp(26) : fatal error C1010: unexpected end of file while looking for precompiled header directive
执行 cl.exe 时出错.
pointer_calculate.exe - 1 error(s), 0 warning(s)
问题分析:
缺少#include "stdafx.h"
stdafx.h在C++中起到的作用是头文件预编译,即把C++工程中使用的MFC头文件预先编译,以后该工程编译时,直接使用预编译的结果,以加快编译速度。