stdafx.h
我在Visual Studio 2010中启动项目时会自动生成一个名为的文件.我需要创建一个跨平台的C++库,所以我不能/不能使用这个头文件.
什么stdafx.h
用于?我可以删除这个头文件吗?
cross-platform visual-studio-2010 stdafx.h visual-studio visual-c++
我正在使用Visual Studio 2005.我创建了一个名为"StdAfx dependancy"的基于MFC的控制台应用程序.IDE为我创建了以下文件.
我CHelper
在Helper.h和Helper.cpp中添加了另一个类,如下所示.
Helper.h:
#pragma once
class CHelper
{
public:
CHelper(void);
~CHelper(void);
};
Run Code Online (Sandbox Code Playgroud)
Helper.cpp
#include "StdAfx.h"
#include "Helper.h"
CHelper::CHelper(void)
{
}
CHelper::~CHelper(void)
{
}
Run Code Online (Sandbox Code Playgroud)
我CHelper
在main函数中创建了一个对象; 为实现这一点,我在StdAfx Dependancy.cpp的第一行添加了Header.h文件,如下所示; 我有以下错误.
d:\ codes\stdafx dependancy\stdafx dependancy\stdafx dependancy.cpp(33):error C2065:'CHelper':未声明的标识符
d:\ codes\stdafx dependancy\stdafx dependancy\stdafx dependancy.cpp(33):error C2146:语法错误:缺少';' 在标识符'myHelper'之前
d:\ codes\stdafx dependancy\stdafx dependancy\stdafx dependancy.cpp(33):error C2065:'myHelper':未声明的标识符
但是当我把它包括在内之后stdafx.h
,错误就消失了.为什么?
// Stdafx dependancy.cpp : Defines the entry point for the console application.
//
#include "Helper.h"
#include "stdafx.h" …
Run Code Online (Sandbox Code Playgroud)