线程函数编译时报错啊,来人啊。!!!

first1 2004-02-22 11:54:50
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_)

...全文
15 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧