我的问题很奇怪。在visual c++
我想用来fuzzylite library
创建一个dll。当我创建我的课,在形式利用图书馆(myclass.h
,myclass.cpp
)项目编译罚款。和Fuzzylite标头包含在myclass.h
但是如果我#include “stdafx.h”
在顶部myclass.cpp
加上(#include “fl/Headers.h”
)或在顶部加上(),stdafx.h
我就会知道100 errors
。任何的想法?
更新1:
//FuzzyCalc.h
#pragma once
#define __DLL_EXPORTS
#ifdef __DLL_EXPORTS
#define __DLL_API __declspec(dllexport)
#else
#define __DLL_API __declspec(dllimport)
#endif
class __DLL_API FuzzyCalc
{
public:
FuzzyCalc();
~FuzzyCalc();
double getOutputValue(double val1, double val2);
};
//FuzzyCalc.cpp
#include "fl/Headers.h"
#include "FuzzyCalc.h"
FuzzyCalc::FuzzyCalc()
{
}
FuzzyCalc::~FuzzyCalc()
{
}
double FuzzyCalc::getOutputValue(double val1, double val2)
{
return 0.0;
}
直到这一点一切正常,程序可以编译并构建成功,但是如果我添加以下代码:
#include "stdafx.h"
#include "fl/Headers.h"
#include "FuzzyCalc.h"
FuzzyCalc::FuzzyCalc()
{
}
FuzzyCalc::~FuzzyCalc()
{
}
double FuzzyCalc::getOutputValue(double val1, double val2)
{
return 0.0;
}
我收到一些类似thease的错误:
Error C2146 syntax error: missing ')' before identifier 'a' fuzzyind fuzzylite\fl\Operation.h 41
Error C2365 'T': redefinition; previous definition was 'template parameter' fuzzyind \fuzzylite\fl\Operation.h 41
Error C2061 syntax error: identifier 'a' fuzzyind \fuzzylite\fl\Operation.h 41
Error C2059 syntax error: ')' fuzzyind \fuzzylite\fl\Operation.h 41
Error C2334 unexpected token(s) preceding ':'; skipping apparent function body fuzzyind \fuzzylite\fl\Operation.h 41
Error C2988 unrecognizable template declaration/definition fuzzyind \fuzzylite\fl\term\Term.h 37
Error C2143 syntax error: missing ';' before 'namespace' fuzzyind \fuzzylite\fl\term\Term.h 37
Error C1004 unexpected end-of-file found fuzzyind fuzzyind\dllmain.cpp 19
只需添加一行,一切都会出错。
我解决了问题。问题是因为在文件stdafx.h中添加了windows.h。在该文件中,存在与Fuzzylite库冲突的宏定义,例如min和max。通过在包含问题解决之前添加#define NOMINMAX,真正的方法是:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from
#define NOMINMAX
#include <windows.h>
#include "fl/Headers.h"
希望这对其他人有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句