首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >gcc错误:预期'=',‘','ASM',或'__attribute__’在'dequeue‘之前

gcc错误:预期'=',‘','ASM',或'__attribute__’在'dequeue‘之前
EN

Stack Overflow用户
提问于 2013-09-27 03:31:39
回答 1查看 2.8K关注 0票数 0

我对C非常陌生,无法解决我的问题,看看过去关于这个编译错误的一些线程。

这是我的密码:

代码语言:javascript
运行
复制
#include <stdio.h>
#include <stdlib.h>

struct PCB{
/*various data fields within the PCB structure*/
/*in this implementation just ID is included*/
int ID;
struct PCB *next;
struct PCB *prev;
}typedef PCB;


void enqueue(PCB **pntrHN, PCB **pntrTL, PCB passedPCB);
PCB dequeue(PCB **pntrHN, PCB **pntrTL);
void print_queue(PCB **pntrTL);
int size_of_queue(PCB **pntrTL); 
void clear_queue(PCB **pntrHN, PCB **pntrTL); 

int main(int argc, char * argv[])
{
PCB **headOfQueue;
PCB **tailOfQueue;
PCB pcbNode;

headOfQueue = malloc(sizeof(PCB*));
tailOfQueue = malloc(sizeof(PCB*));
*headOfQueue = 0;
*tailOfQueue = 0;
for(i=0; j<100; j++)
{
    PCB temp;
    temp.ID = rand()%30000+20001;
    enqueue(headOfQueue,tailOfQueue,temp);
}

print_queue(tailOfQueue);
int size = size_of_queue(tailOfQueue);
printf("Size of queue: %d\n", size);
clear_queue(headOfQueue, tailOfQueue);
size = size_of_queue(tailOfQueue);
printf("Size of queue now: %d\n", size);
return(0);
}
/*enqueue is here*/
PCB dequeue(PCB **pntrHN, PCB **pntrTL)
{
PCB *tempHead; /*temp var for new head*/
PCB returnVal;

if((*pntrHN)->next !=0){
printf("nodes next is not 0");
exit(0);
}
if(*pntrHN == 0){
printf("dequeued an empty queue");
exit(0);
}
if(*pntrTL == 0){
printf("dequeued empty queue");
printf("head is not zero but tail is");
exit(0);
}
returnVal = **pntrHN; /*get data for return*/

if(*pntrHN == *pntrTL){
*pntrTL = 0;
tempHead = 0;
}else{
tempHead = (*pntrHN)->prev; /*get new head*/
tempHead ->next = 0;
}
free(*pntrHN); /*free old head*/ 
*pntrHN = tempHead; /*set class attribute to new tail*/
return returnVal;
}

void clear_queue(PCB **pntrHN, PCB **pntrTL)
{
PCB holder;
if(*pntrTL != 0){
    while(*pntrHN != 0){
        (*pntrHN)->prev = *pntrHN;
        holder = dequeue(**pntrHN, **pntrTL);
    }
}
}
}

我的语法还好吗?我真不知道我现在哪里出了问题。我通过ssh使用notepad++和gcc。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-27 03:33:53

将结构更新为

代码语言:javascript
运行
复制
typedef struct {
   /*various data fields within the PCB structure*/
   /*in this implementation just ID is included*/
   int ID;
   struct PCB *next;
   struct PCB *prev;
}PCB;

1.

代码语言:javascript
运行
复制
In function main:<br/>
undefined reference to enqueue
undefined reference to print_queue
undefined reference to size_of_queue
undefined reference to size_of_queue
  1. 变化

代码语言:javascript
运行
复制
for(i=0; j<100; j++)

代码语言:javascript
运行
复制
for(j=0; j<100; j++)

并声明j;

按语法

dequeue(**pntrHN, **pntrTL);更改为dequeue(pntrHN, pntrTL);

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

https://stackoverflow.com/questions/19042253

复制
相关文章

相似问题

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