Xcode错误编译c ++期望的成员名称或&#39 ;;'在声明说明符之后

时间:2015-07-27 23:32:56

标签: c++ xcode objective-c++

我在c ++库(openNN)中遇到检查方法的问题我试图在Xcode中编译。我将使用其中一种方法的示例,因为我怀疑它们都是由同一问题引起的。

标题声明,我收到错误:
预期会员姓名或';'在声明说明符之后。

mysql_*

功能定义:

void check(void) const;

如果我将标题中的定义更改为
void InverseSumSquaredError::check(void) const { std::ostringstream buffer; // Neural network stuff if(!neural_network_pointer) { buffer << "OpenNN Exception: InverseSumSquaredError class.\n" << "void check(void) const method.\n" << "Pointer to neural network is NULL.\n"; throw std::logic_error(buffer.str().c_str()); } const MultilayerPerceptron* multilayer_perceptron_pointer = neural_network_pointer->get_multilayer_perceptron_pointer(); if(!multilayer_perceptron_pointer) { buffer << "OpenNN Exception: InverseSumSquaredError class.\n" << "void check(void) const method.\n" << "Pointer to multilayer perceptron is NULL.\n"; throw std::logic_error(buffer.str().c_str()); } const unsigned int inputs_number = multilayer_perceptron_pointer->count_inputs_number(); const unsigned int outputs_number = multilayer_perceptron_pointer->count_outputs_number(); if(inputs_number == 0) { buffer << "OpenNN Exception: InverseSumSquaredError class.\n" << "void check(void) const method.\n" << "Number of inputs in multilayer perceptron object is zero.\n"; throw std::logic_error(buffer.str().c_str()); } if(outputs_number == 0) { buffer << "OpenNN Exception: InverseSumSquaredError class.\n" << "void check(void) const method.\n" << "Number of outputs in multilayer perceptron object is zero.\n"; throw std::logic_error(buffer.str().c_str()); } // Mathematical model stuff if(!mathematical_model_pointer) { buffer << "OpenNN Exception: InverseSumSquaredError class.\n" << "void check(void) const method.\n" << "Pointer to mathematical model is NULL.\n"; throw std::logic_error(buffer.str().c_str()); } // Data set stuff if(!data_set_pointer) { buffer << "OpenNN Exception: InverseSumSquaredError class.\n" << "void check(void) const method.\n" << "Pointer to data set is NULL.\n"; throw std::logic_error(buffer.str().c_str()); } // Final solutions error stuff }
我最终得到了错误:
会员的额外资格&#39;检查&#39;

我目前正在使用方言C ++ 98和Library libc ++。 Xcode被设置为将源代码编译为Objective-C ++,它可以处理大多数其他错误。

我无法想到与此问题相关的任何其他内容,它让我难以忍受数小时,因此非常感谢任何类型的帮助。

1 个答案:

答案 0 :(得分:6)

不知道您的确切设置,但是当源代码引用AssertMacros.h并且还有check方法的某些定义时,已经historical reports。在我的测试代码中:

#include <stdio.h>
#include <AssertMacros.h>

class InverseSumSquaredError {
public:
   void check(void) const;
}

我发现了同样的错误。包括这一行:

#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0

在包含AssertMacros.h之前解决问题。