【问题标题】:error C2143: syntax error : missing ')' before '*'错误 C2143:语法错误:在 '*' 之前缺少 ')'
【发布时间】:2011-03-26 16:56:17
【问题描述】:

我有以下头文件,但不断收到:语法错误:在 '*' 之前缺少 ')' 在原型声明行上。有什么问题?

typedef struct queue{
int count;
int first;
int last;
int *q;
};

void init_queue(queue *q);
void enqueue(queue *q, int x);
int dequeue(queue *q);
int empty(queue *q);

【问题讨论】:

  • @payne 在所有原型线上

标签: c prototype struct typedef header-files


【解决方案1】:

你从来没有完成你的 typedef。你可能打算这样做:

typedef struct queue{
int count;
int first;
int last;
int *q;
} queue;

您需要在 typedef 的末尾为您的类型定义一个别名。如果您没有 typedef,则必须像这样编写原型:

void init_queue(struct queue *q);
// etc.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    • 2011-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多