对于编译还是没弄明白,尤其是多个头文件之间的相互包含。
比如,为什么一个工程中每个CPP文件都要包含#include "stdafx.h"
今天遇到一个问题,不知道怎么弄了。
error C2011: 'CCriticalSection' : 'class' type redefinition
类似这样的错误。
ForeSightDlg.h中添加一个#include "TimeThread.h" 就会报上边的错误,否则不会 ForeSightDlg.h
中 #include "TimeThread.h" ForeSightDlg.cpp 中
#include "stdafx.h"
#include "Foresight.h"
#include "ForesightDlg.h"
#include "Utils.h" 其中 Utils.h中包含 CCriticalSection的定义。
TimeThread.h中
#if !defined(AFX_GETTimeTHREAD_H__E556DA03_4987_4013_802A_C2A42E953C5C__INCLUDED_)
#define AFX_GETTimeTHREAD_H__E556DA03_4987_4013_802A_C2A42E953C5C__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GetTimeThread.h : header file
//#include <afxmt.h> //CEVENT TimeThread.cpp中
#include "stdafx.h"
#include "ForeSight.h"
#include "ForeSightDlg.h"
#include "TimeThread.h"
我就不明白,为什么 ForeSightDlg.h中添加一个#include "TimeThread.h" 就会报error C2011: 'CCriticalSection' : 'class' type redefinitio的错误。
TimeThread.h 会带来什么影响?
比如,为什么一个工程中每个CPP文件都要包含#include "stdafx.h"
今天遇到一个问题,不知道怎么弄了。
error C2011: 'CCriticalSection' : 'class' type redefinition
类似这样的错误。
ForeSightDlg.h中添加一个#include "TimeThread.h" 就会报上边的错误,否则不会 ForeSightDlg.h
中 #include "TimeThread.h" ForeSightDlg.cpp 中
#include "stdafx.h"
#include "Foresight.h"
#include "ForesightDlg.h"
#include "Utils.h" 其中 Utils.h中包含 CCriticalSection的定义。
TimeThread.h中
#if !defined(AFX_GETTimeTHREAD_H__E556DA03_4987_4013_802A_C2A42E953C5C__INCLUDED_)
#define AFX_GETTimeTHREAD_H__E556DA03_4987_4013_802A_C2A42E953C5C__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GetTimeThread.h : header file
//#include <afxmt.h> //CEVENT TimeThread.cpp中
#include "stdafx.h"
#include "ForeSight.h"
#include "ForeSightDlg.h"
#include "TimeThread.h"
我就不明白,为什么 ForeSightDlg.h中添加一个#include "TimeThread.h" 就会报error C2011: 'CCriticalSection' : 'class' type redefinitio的错误。
TimeThread.h 会带来什么影响?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货