gpt4 book ai didi

c - 结构范围

转载 作者:行者123 更新时间:2023-11-30 17:55:45 25 4
gpt4 key购买 nike

#include <stdio.h>
#include "prique.h"

void main()
{
_pqueue *test;
queue_init(&test);
...

我不知道为什么会收到此错误。

error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token|

头文件的结构为

typedef struct _pqueue
{
int size;
struct queue_node *first;
}_pqueue;

我已经正确定义了结构。我看到一些讨论说这个错误与范围有关,但不知道如何修复它。

最佳答案

不确定这是否是这里的问题,但有些编译器无法识别 void main(),所以:

int main()

否则它可能是您的 prique.h 模块中的某些内容...

此外,如果您的queue_node以相同的方式定义(typedef structqueue_node {...}queue_node),那么您可能不需要struct关键字:

typedef struct _pqueue
{
int size;
queue_node *first;
} _pqueue;

关于c - 结构范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14019886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com