Xcode编译C ++预期成员名称或';'时出错声明后声明符 [英] Xcode error compiling c++ Expected member name or ';' after declaration specifiers

查看:275
本文介绍了Xcode编译C ++预期成员名称或';'时出错声明后声明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Xcode中进行编译的c ++库(openNN)中的检查方法存在问题.我将以其中一种方法为例,因为我怀疑它们都是由同一问题引起的.

I'm having issues with the checking methods in a c++ library (openNN) i'm trying to compile in Xcode. I'll use an example of one of the methods as i suspect they are all caused by the same issue.

出现错误的标头声明:
期望的会员名称或';'在声明说明符之后.

Header declaration where i get the error:
Expected member name or ';' after declaration specifiers.

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

}

如果我将标题中的定义更改为
void InverseSumSquaredError::check(void) const;
我最终遇到错误:
成员检查"的额外资格

我当前正在使用方言C ++ 98和库libc ++. Xcode设置为将源代码编译为Objective-C ++,可解决大多数其他错误.

If i change the definition in the header to
void InverseSumSquaredError::check(void) const;
I end up with the error:
Extra qualification on member 'check'

I'm currently using the dialect C++98 and Library libc++. Xcode is set to compile sources as Objective-C++ which takes care of most of the other errors.

我想不出与此问题相关的任何其他信息,因为它困扰了我好几个小时,所以非常感谢您提供任何类型的帮助.

I can't think of anything else relevant to this issue, it's had me stumped for hours, so any type of help is much appreciated.

推荐答案

不知道您的确切设置,但是有AssertMacros.h并且还具有check方法的某些定义时,="nofollow noreferrer">报告.在我的测试代码中:

Don't know your exact setup, but there have been historical reports when source code references AssertMacros.h and also has some definition of a check method. In my test code:

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

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

我观察到相同的错误.包括以下行:

I observed the same error. Including the line:

#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0

在包含AssertMacros.h之前可以解决此问题.

prior to including AssertMacros.h fixes the issue.

这篇关于Xcode编译C ++预期成员名称或';'时出错声明后声明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆