下面是我的一些C++代碼。我得到這個錯誤:本地函數定義不合法
C2601: 'main' : local function definitions are illegal
爲什麼我得到這個?
BOOL CBasicApp::InitInstance()
{
typedef BOOL (__stdcall *pFunc)();
int main(int argc, char* argv[])
{
pFunc pf = 0;
HMODULE hMod = 0;
hMod = LoadLibrary("dbgghelp.dll");
if (!hMod)
{
printf("File not found: Dbgghelp.DLL\n");
return 0;
}
pf = GetProcAddress(hMod,"L100A6F95");
嘗試移動typedef出方法。將其放入.h文件或導入後。 – Tav
我認爲錯誤信息很清楚。在C++中,你不能在本地定義一個函數(即直接在另一個函數中)。 – cpplearner