FuffyLITE Visual C++的陌生行为
我的问题很奇怪。 在Visual C++中,我想使用FuffLITE库来创建DLL。 当我使用myclass.h、myclass.cpp格式的库创建我的类时,项目编译得很好。 和fuzzylite头包含在myclass.h中 但是如果我在myclass.cpp的顶部添加include“stdafx.h”,或者在stdafx.h中添加include“fl/Headers.h”,我会得到大约100个错误。 有什么想法吗 更新1: 在此之前,一切正常,程序编译和构建成功,但如果我添加以下内容:FuffyLITE Visual C++的陌生行为,c++,visual-c++,C++,Visual C++,我的问题很奇怪。 在Visual C++中,我想使用FuffLITE库来创建DLL。 当我使用myclass.h、myclass.cpp格式的库创建我的类时,项目编译得很好。 和fuzzylite头包含在myclass.h中 但是如果我在myclass.cpp的顶部添加include“stdafx.h”,或者在stdafx.h中添加include“fl/Headers.h”,我会得到大约100个错误。 有什么想法吗 更新1: 在此之前,一切正常,程序编译和构建成功,但如果我添加以下内容: #in
#include "stdafx.h"
#include "fl/Headers.h"
#include "FuzzyCalc.h"
FuzzyCalc::FuzzyCalc()
{
}
FuzzyCalc::~FuzzyCalc()
{
}
double FuzzyCalc::getOutputValue(double val1, double val2)
{
return 0.0;
}
我遇到了一些错误,例如:
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。
通过在包含问题之前添加定义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"
希望这对其他人有所帮助。构建一个示例,该示例是您需要的main和header。然后逐行添加所需的功能,直到它停止编译。如果这并不能使问题变得明显,请编辑您的问题以添加代码。这就是我们所说的MCVE,但您已经知道,因为您阅读了网站帮助和关于如何编写好问题的部分。
// 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"