C的错误:unresolved external symbol _main

来源:百度知道 编辑:UC知道 时间:2024/05/03 07:04:44
大家帮我看看这是什么问题:
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Hello.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

代码:
#define STRICT
#include <windows.h>
#include <tchar.h>
#include <assert.h>

const TCHAR szOperation[] = _T("open");
const TCHAR szAddress[] = _T("www.baidu.com");
int WINAPI WinMain(HINSTANCE hInst,
HINSTANCE,LPSTR lpCmd,
int nShow)
{
HINSTANCE hRslt = ShellExecute(NULL,szOperation,
szAddress,NULL,NULL,SW_SHOWNORMAL);
assert(hRslt > (HINSTANCE) HINSTANCE_ERROR);
return 0;
}

LZ相当有才啊。
我用的VC2005 too.
新建一个WIN32空工程,添加一个main.cpp,直接拷贝你的代码进去。
运行成功。不过造成了异常!我运!
程序不能正常终结啊。
你可以在WinMain前面加个_t试试。
#define STRICT
#include <windows.h>
#include <tchar.h>
#include <assert.h>

const TCHAR szOperation[] = _T("open");
const TCHAR szAddress[] = _T("www.baidu.com");
int WINAPI _tWinMain(HINSTANCE hInst,
HINSTANCE,LPSTR lpCmd,
int nShow)
{
HINSTANCE hRslt = ShellExecute(NULL,szOperation,
szAddress,NULL,NULL,SW_SHOWNORMAL);
assert(hRslt > (HINSTANCE) HINSTANCE_ERROR);
return 0;
}