为什么显示错误:在结构“ {”前加“;”,标识符或“(”

时间:2018-09-09 14:28:35

标签: c ubuntu

我遇到错误

  

CC src / main.c在src / main.c中包含的文件中:8:0:   src /../ include / linkedlist.h:4:1:错误:预期为“;”,标识符或   ‘(’在'struct'struct施主Node * getNewDonorNode()之前; ^ ~~~~~   Makefile:294:目标“ obj / main.o”的配方失败:***   [obj / main.o]错误1

在此处查看代码-https://github.com/aman-roy/BloodBank

链表.h

#ifndef LINKEDLIST_H_
#define LINKEDLIST_H_

struct donorNode* getNewDonorNode();
struct acceptorNode * getNewAcceptorNode();

struct donorBox* donorDBtoLL();
struct acceptorBox* acceptorDBtoLL();

void distroyAcceptor(struct acceptorNode *);
void distroyDonor(struct donorNode *);

struct donorNode * insertAtTopDonor(struct donorNode *, struct donorNode *);
struct acceptorNode * insertAtTopAcceptor(struct acceptorNode *, struct acceptorNode *);

#endif

linkedlist.c

#include <stdlib.h>
#include <stdio.h>

#include "../include/linkedlist.h"
#include "../include/containers.h"
#include "../include/utilities.h"
#include "../include/color.h"

struct donorNode * getNewDonorNode()
{
    struct donorNode *temp = (struct donorNode *)malloc(sizeof(struct donorNode));
    temp->next = NULL;
    return temp;
}

struct acceptorNode * getNewAcceptorNode()
{
    struct acceptorNode *temp = (struct acceptorNode *)malloc(sizeof(struct acceptorNode));
    temp->next = NULL;
    return temp;
}


struct donorBox* donorDBtoLL()
{
    FILE *fp = loadFile('d');
    if (!fp)
       return NULL;
    struct donorNode *temp = getNewDonorNode();
    struct donorBox *box = (struct donorBox *)malloc(sizeof(struct donorBox));
    if(fread(&temp->data,sizeof(temp->data),1,fp))
    {
        int count = 0;
        struct donorNode *head = NULL;
        struct donorNode *front = NULL;
        rewind(fp);

        while(fread(&temp->data,sizeof(temp->data),1,fp))
        {
            if (head == NULL)
            {
                head = temp;
                front = head;
                temp = getNewDonorNode();
                count++;
                continue;
            }
            head->next = temp;
            head = temp;
            count++;
            temp = getNewDonorNode();
        }
        free(temp);
        fclose(fp);

        box->head = front;
        box->count = count;
    }
    else
    {
        box->head = NULL;
        box->count = 0;
        free(temp);
        printf(TD_BOLD TC_RED TD_UNDERLINE"\t\t\t\tNO DATA AVAILABLE!\n");
    }
    return box;
}



struct acceptorBox *acceptorDBtoLL()
{
    FILE *fp = loadFile('a');
    if (!fp)
       return NULL;
    struct acceptorNode *temp = getNewAcceptorNode();
    struct acceptorBox *box = (struct acceptorBox *)malloc(sizeof(struct acceptorBox));
    if(fread(&temp->data,sizeof(temp->data),1,fp))
    {
        int count = 0;
        struct acceptorNode *head = NULL;
        struct acceptorNode *front = NULL;
        rewind(fp);

        while(fread(&temp->data,sizeof(temp->data),1,fp))
        {
            if (head == NULL)
            {
                head = temp;
                front = head;
                temp = getNewAcceptorNode();
                count++;
                continue;
            }
            head->next = temp;
            head = temp;
            count++;
            temp = getNewAcceptorNode();
        }
        free(temp);
        fclose(fp);

        box->head = front;
        box->count = count;
    }
    else
    {
        box->head = NULL;
        box->count = 0;
        free(temp);
        printf(TD_BOLD TC_RED TD_UNDERLINE"\t\t\t\tNO DATA AVAILABLE!\n");
        sleep(2);
    }
    return box;
}

void distroyAcceptor(struct acceptorNode *head)
{
    if (head == NULL)
    {
        return;
    }
    distroyAcceptor(head->next);
    free(head);
}

void distroyDonor(struct donorNode *head)
{
    if (head == NULL)
    {
        return;
    }
    distroyDonor(head->next);
    free(head);
}

struct donorNode * insertAtTopDonor(struct donorNode * current, struct donorNode * head)
{
    struct donorNode *temp = (struct donorNode *)malloc(sizeof(struct donorNode));
    temp->data = head->data;

    if (current == NULL)
    {
        current = temp;
        current->next = NULL;
    }
    else
    {
        temp->next = current;
        current = temp;
    }
    return current;
}

struct acceptorNode * insertAtTopAcceptor(struct acceptorNode * current, struct acceptorNode * head)
{
    struct acceptorNode *temp = (struct acceptorNode *)malloc(sizeof(struct acceptorNode));
    temp->data = head->data;

    if (current == NULL)
    {
        current = temp;
        current->next = NULL;
    }
    else
    {
        temp->next = current;
        current = temp;
    }
    return current;
}

1 个答案:

答案 0 :(得分:0)

我撤回了仓库:diffs = (my_date - df.index) > pd.Timedelta(0) res = df[0].iat[-(diffs[::-1].argmax() + 1)] # 110

然后我启动了这样的广告:git clone https://github.com/aman-roy/BloodBank.git

一切正常,我能够启动该程序:make

我相信您尝试只编译某些文件,而不编译所有文件。

因此,请尝试提取存储库并将其全部编译,它将起作用。

如果您只想使用linkedList,则需要首先在./bin/BlodBank中添加包含定义的文件:linkedlist.c

所以它应该像这样:

include/containers.h