And*_*kha 53 c++ compiler-errors precompiled-headers visual-studio-2008 visual-c++
我希望你能帮助我,因为我不知道发生了什么.我在尝试将Beecrypt库添加到我的项目时遇到以下错误:
致命错误C1010:查找预编译头时意外结束文件.你忘了在你的来源添加'#include"stdafx.h"'吗?
其实我没有忘记将#include"stdafx"添加到我的源代码中.编译器将错误指向此.cxx文件的末尾:
#define BEECRYPT_CXX_DLL_EXPORT
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "beecrypt/c++/security/SecureRandom.h"
#include "beecrypt/c++/security/SecureRandomSpi.h"
#include "beecrypt/c++/security/Security.h"
using namespace beecrypt::security;
SecureRandom* SecureRandom::getInstance(const String& algorithm) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(algorithm, "SecureRandom");
assert(dynamic_cast<SecureRandomSpi*>(tmp->cspi));
SecureRandom* result = new SecureRandom(reinterpret_cast<SecureRandomSpi*>(tmp->cspi), tmp->prov, tmp->name);
delete tmp;
return result;
}
SecureRandom* SecureRandom::getInstance(const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException)
{
Security::spi* tmp = Security::getSpi(type, "SecureRandom", provider);
assert(dynamic_cast<SecureRandomSpi*>(tmp->cspi));
SecureRandom* result = new SecureRandom(reinterpret_cast<SecureRandomSpi*>(tmp->cspi), tmp->prov, tmp->name);
delete tmp;
return result;
}
SecureRandom* SecureRandom::getInstance(const String& type, const Provider& provider) throw (NoSuchAlgorithmException)
{
Security::spi* tmp = Security::getSpi(type, "SecureRandom", provider);
assert(dynamic_cast<SecureRandomSpi*>(tmp->cspi));
SecureRandom* result = new SecureRandom(reinterpret_cast<SecureRandomSpi*>(tmp->cspi), tmp->prov, tmp->name);
delete tmp;
return result;
}
void SecureRandom::getSeed(byte* data, int size)
{
entropyGatherNext(data, size);
}
SecureRandom::SecureRandom()
{
Security::spi* tmp = Security::getFirstSpi("SecureRandom");
assert(dynamic_cast<SecureRandomSpi*>((SecureRandomSpi*) tmp->cspi));
_rspi = (SecureRandomSpi*) tmp->cspi;
_type = tmp->name;
_prov = tmp->prov;
delete tmp;
}
SecureRandom::SecureRandom(SecureRandomSpi* rspi, const Provider* provider, const String& type)
{
_rspi = rspi;
_prov = provider;
_type = type;
}
SecureRandom::~SecureRandom()
{
delete _rspi;
}
void SecureRandom::generateSeed(byte* data, int size)
{
_rspi->engineGenerateSeed(data, size);
}
void SecureRandom::setSeed(const byte* data, int size)
{
_rspi->engineSetSeed(data, size);
}
void SecureRandom::nextBytes(byte* data, int size)
{
_rspi->engineNextBytes(data, size);
}
const String& SecureRandom::getType() const throw ()
{
return _type;
}
const Provider& SecureRandom::getProvider() const throw ()
{
return *_prov;
}
Run Code Online (Sandbox Code Playgroud)
这是h文件:
#ifndef _CLASS_BEE_SECURITY_SECURERANDOM_H
#define _CLASS_BEE_SECURITY_SECURERANDOM_H
#include "beecrypt/beecrypt.h"
#ifdef __cplusplus
#include "beecrypt/c++/security/SecureRandomSpi.h"
using beecrypt::security::SecureRandomSpi;
#include "beecrypt/c++/security/Provider.h"
using beecrypt::security::Provider;
#include "beecrypt/c++/security/NoSuchAlgorithmException.h"
using beecrypt::security::NoSuchAlgorithmException;
#include "beecrypt/c++/security/NoSuchProviderException.h"
using beecrypt::security::NoSuchProviderException;
namespace beecrypt {
namespace security {
/*!\ingroup CXX_SECURITY_m
*/
class BEECRYPTCXXAPI SecureRandom : public Object
{
public:
static SecureRandom* getInstance(const String& type) throw (NoSuchAlgorithmException);
static SecureRandom* getInstance(const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException);
static SecureRandom* getInstance(const String& type, const Provider& provider) throw (NoSuchAlgorithmException);
static void getSeed(byte*, int);
private:
SecureRandomSpi* _rspi;
const Provider* _prov;
String _type;
protected:
SecureRandom(SecureRandomSpi* spi, const Provider* provider, const String& type);
public:
SecureRandom();
virtual ~SecureRandom();
void generateSeed(byte*, int);
void nextBytes(byte*, int);
void setSeed(const byte*, int);
const String& getType() const throw ();
const Provider& getProvider() const throw ();
};
}
}
#endif
#endif
Run Code Online (Sandbox Code Playgroud)
很抱歉这么多代码.
Wac*_*cek 127
转到SolutionExplorer(应该已经可见,如果没有使用菜单:View-> SolutionExplorer).
在解决方案树中找到您的.cxx文件,右键单击它并从弹出菜单中选择"属性".您将获得包含文件属性的窗口.
使用左侧的树转到"C++ /预编译标题"部分.在窗口的右侧,您将获得三个属性.将名为"Create/Use Precompiled Header"的属性设置为"Not Using Precompiled Headers"的值.
小智 15
如果在项目中未使用预编译头,请将源文件的"创建/使用预编译头"属性设置为"不使用预编译头".要设置此编译器选项,请按照下列步骤操作:
Properties.C/C++文件夹.Precompiled Headers节点.Create/Use Precompiled Header,然后单击"确定" Not Using Precompiled Headers.Naw*_*waz 11
你确实忘了stdafx.h在你的来源中加入(因为我看不到你的代码).如果没有,请确保#include "stdafx.h"是文件中的第一行.cpp,否则即使您已包含"stdafx.h"在源文件中(但不在文件的最开头),您也会看到相同的错误.
我也有这个错误,但对于一个.h文件.修复是进入文件Properties(通过解决方案资源管理器的文件弹出菜单)并正确设置文件类型.它被设置为C/C++ Compiler而不是正确的C/C++ header.
在包含任何其他头文件之前,该行#include "stdafx.h" 必须是每个源文件顶部的第一行.
如果您显示的是整个.cxx文件,那么您确实忘记包含stdafx.h在该文件中.
当我在命名新的 Win32 控制台应用程序后忘记从向导中的附加选项中取消选中预编译标头时,我遇到了该错误。
因为我不需要 stdafx.h 库,所以我通过转到“项目”菜单删除它,然后单击“属性”或“[我们项目的名称]属性”或只需按Alt + F7。在配置旁边的下拉列表中,选择“所有配置”。下面是一个树节点,单击Configuration Properties,然后单击C/C++。在右侧窗格中,选择创建/使用预编译头,然后选择不使用预编译头。
| 归档时间: |
|
| 查看次数: |
107675 次 |
| 最近记录: |