3

请看以下文件:(它是一个完整的文件)

#ifndef TEES_ALGORITHM_LIBRARY_WRAPPER_H
#define TEES_ALGORITHM_LIBRARY_WRAPPER_H

#ifdef _TEES_COMPILE_AS_LIB
#include <dfa\Includes\DFC_algorithms.hpp>
#include <DFA\FuzzyClassifier\FuzzyAlgorithmIntialization\InitFuzzyAlgorithm.hpp>
typedef teesalgorithm::tees_fuzzy_algorithms algorithms_switchyard_class;
#else
#include <DFA\Includes\commercial_algorithms.hpp>
//An incomplete class to hide implementation
class algorithms_switchyard_class;
#endif

class AlgorithmLibraryWrapper {
algorithms_switchyard_class * algorithmPtr_;

typedef teesalgorithm::tees_paramObj paramObj_type;
typedef teesalgorithm::tees_errorObj errorObj_type;  
typedef teesalgorithm::tees_statusObj statusObj_type;
typedef teesalgorithm::tees_dataObj dataObj_type;
typedef teesalgorithm::tees_outputObj outputObj_type;

public:

AlgorithmLibraryWrapper(const std::string& sAlgName, paramObj_type& paramObj,     errorObj_type& errObj, statusObj_type& statusObj, const char* sFilePath);
static bool dataReader(const std::string& sFileName, dataObj_type& dataObj,     errorObj_type& errObj, statusObj_type& statusObj);
bool runalgorithm(const dataObj_type& dataObj, outputObj_type& outObj, errorObj_type& errObj, statusObj_type& statusObj); 
~AlgorithmLibraryWrapper();

};


#ifdef _TEES_USE_COMPILED_ALGORITHM_LIB
#   ifdef _MSC_VER
    #if _MSC_VER < 1400  // If VC 2003
        #ifdef _DEBUG
            #error No AlgorithmLibWrapper libraries compiled for this version of VC
        #else
            #error No AlgorithmLibWrapper libraries compiled for this version of VC
        #endif
    #elif defined(UNDER_CE)  // Win CE
        #ifdef _DEBUG
            #pragma comment( lib, "AlgorithmLibWrapperCEd" )
        #else
            #pragma comment( lib, "AlgorithmLibWrapperCE" )
        #endif
    #else  // If VC 2005
        #ifdef _DEBUG
            #pragma comment( lib, "AlgorithmLibWrapperd" )
        #else
            #pragma comment( lib, "AlgorithmLibWrapper" )
        #endif
    #endif
#endif 
#endif


#endif //TEES_ALGORITHM_LIBRARY_WRAPPER_H

我收到以下错误;我不知道为什么。我也手动计算了预处理器指令。

AlgorithmLibraryWrapper.hpp:10:1: 未终止#ifdef
AlgorithmLibraryWrapper.hpp:7:1: 未终止#ifndef

我正在使用糟糕的 vxWorks gcc 编译器。请让我知道是我的错还是编译器的错。

4

6 回答 6

4

可能问题出在包含的文件中(如果实际上有不平衡的#if/ #endifs.

我会尝试使用另一个编译器进行预处理。您可以为此使用 gcc,没关系它不会编译。只需获取 gcc(或 MinGW,如果您在 Windows 上)并运行

cpp -Iinclude_direcories your_file

或者,如果您不喜欢 gcc,请获取 MSVC Express 版本。同样,您可以预处理甚至无法编译的代码,因此非工作库等没有问题。

大多数编译器都有一个选项,可以为您提供预处理器的输出,以便您检查它在做什么。例如,

gcc -E file.c >file.preproc

将为您提供预处理的源代码,以便您检查#if 与 #endif 的平衡。

于 2009-02-20T00:07:53.703 回答
3

猜测一下,您从中#include 的文件之一有一个不匹配的#ifdef/#endif 对。您需要查看所有文件(正如预处理器所做的那样),而不仅仅是这个文件。

于 2009-02-20T00:08:49.690 回答
1

正如其他人所指出的,这很可能是由于不匹配的包括警卫。

如果您包含的文件在您的控制之下(即不是第 3 方封闭源代码库的一部分),您可以考虑替换 #ifndef 等。人。使用 #pragma 一次的守卫(用于防止多次包含)。这将消除预处理器指令不匹配的可能性。

需要注意的一点是,pragma once是非标准的,所以它只有在你的编译器支持的情况下才会起作用。

于 2009-02-20T00:48:21.983 回答
0

我尝试使用 vs 6.0 编译您的源代码,但没有收到您提到的错误。正如其他人所说,错误可能来自包含的头文件。为了让我编译你的代码,我需要评论上面的标题。

请检查上述标题一次。

于 2009-02-20T03:40:54.097 回答
0

我将通过逐个注释掉部分并尝试确定哪个部分导致错误来调试它。

可能是您的编译器不喜欢嵌套的 #ifdefs 或没有正确解释语法。也许它不喜欢#pragmas。

于 2009-02-20T03:54:56.497 回答
0

这是一个很长的镜头,但在您的源文件中,您有以下行:

#   ifdef _MSC_VER

#' ' 字符和指令名称 ( ifdef)之间有空格。这在 C/C++ 中有效;但是,它并不太常见,所以如果奇怪的编译器被它卡住了,我也不会感到很惊讶。

于 2009-02-20T05:08:52.527 回答