加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Xcode错误编译c预期成员名称或’;’在声明说明符之后

发布时间:2020-12-14 17:57:29 所属栏目:百科 来源:网络整理
导读:我在c库(openNN)中检查方法有问题,我正在尝试在 Xcode中编译.我将使用其中一种方法的示例,因为我怀疑它们都是由同一问题引起的. 标题声明,我得到错误: 预期会员名称或’;’在声明说明符之后. void check(void) const; 功能定义: void InverseSumSquaredErr
我在c库(openNN)中检查方法有问题,我正在尝试在 Xcode中编译.我将使用其中一种方法的示例,因为我怀疑它们都是由同一问题引起的.

标题声明,我得到错误:
预期会员名称或’;’在声明说明符之后.

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和Library libc.
Xcode被设置为将源代码编译为Objective-C,它负责处理大多数其他错误.

我想不出任何与此问题相关的事情,它让我难以忍受了几个小时,所以任何类型的帮助都非常感激.

解决方法

不知道您的确切设置,但是当源代码引用AssertMacros.h并且还有一些检查方法的定义时,已经有 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之前修复了这个问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读