线程函数编译时报错啊,来人啊。!!!
Generating Code...
Linking...
Thread_SDK.obj : error LNK2005: "unsigned int __cdecl MineSubThread(void *)" (?MineSubThread@@YAIPAX@Z) already defined in SubThread.obj
Thread_SDK.obj : warning LNK4006: "unsigned int __cdecl MineSubThread(void *)" (?MineSubThread@@YAIPAX@Z) already defined in SubThread.obj; second definition ignored
为什么?
我试图定义一个全局线程函数MineSubThread,而编译出错时提到的 SubThread 是这个全局线程函数中要使用的一个功能类。
########################## 代码如下 #############################
// Thread_SDK.h : main header file for the THREAD_SDK DLL
//
#if !defined(AFX_THREAD_SDK_H__E495EDD9_382B_4632_96E3_5C2AF8E9201F__INCLUDED_)
#define AFX_THREAD_SDK_H__E495EDD9_382B_4632_96E3_5C2AF8E9201F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include ".\MessHead.h"
#include "SubThread.h"
/////////////////////////////////////////////////////////////////////////////
// CThread_SDKApp
// See Thread_SDK.cpp for the implementation of this class
//
//--------------子线程函数体--------------//
UINT MineSubThread(LPVOID pParam)
{
CSubThread c_SubThread;
。。。。。(省略)
return 0;
}
//--------------子线程函数体--------------//
class CThread_SDKApp : public CWinApp
{
public:
void GetOverMsg();
void GetEventMsg();
CThread_SDKApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CThread_SDKApp)
//}}AFX_VIRTUAL
//{{AFX_MSG(CThread_SDKApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
afx_msg LRESULT GetOverMsg(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT GetEventMsg(WPARAM wParam, LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_THREAD_SDK_H__E495EDD9_382B_4632_96E3_5C2AF8E9201F__INCLUDED_)