首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译c++预期成员名或“;”后声明说明符时出现Xcode错误

编译c++预期成员名或“;”后声明说明符时出现Xcode错误
EN

Stack Overflow用户
提问于 2015-07-27 23:32:55
回答 1查看 20.5K关注 0票数 6

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

标题声明,其中我得到了错误:

声明说明符后的预期成员名称或“;”。

代码语言:javascript
复制
void check(void) const;

功能定义:

代码语言:javascript
复制
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

}

如果我将标题中的定义更改为

void InverseSumSquaredError::check(void) const;

我最后得到了一个错误:

成员“支票”的额外资格

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

我想不出任何与这个问题相关的事情,它让我困惑了好几个小时,所以任何类型的帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-28 01:23:34

不知道您的确切设置,但是当源代码引用历史 报告时,已经出现了AssertMacros.h,并且有一些check方法的定义。在我的测试代码中:

代码语言:javascript
复制
#include <stdio.h>
#include <AssertMacros.h>

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

我观察到了同样的错误。包括以下内容:

代码语言:javascript
复制
#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0

在包含AssertMacros.h之前,解决了这个问题。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31665095

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档