[英]error: expected ‘{’ before ‘*’ token struct (C programming help)
I am getting the following error when I try to compile and run my code.尝试编译和运行代码时出现以下错误。 " error: expected '{' before '*' token struct ".
“错误:在'*'令牌结构之前预期'{'”。
The code it is referring to:
#ifndef node
#define node
struct node
{
int datum;
struct node * next;
} ;
#endif
The above code is for a user-defined header file called "node.h".上面的代码是一个名为“node.h”的用户定义的 header 文件。 It will be used to create a linked list.
它将用于创建链接列表。
#define node
That will replace with an empty token wherever there is a node
after that point.在该点之后有
node
的任何地方都将替换为空令牌。 So after preprocessing the code becomes:所以预处理后的代码变成:
struct
{
int datum;
struct * next;
} ;
So need to pick a name for the define
that is not used as an identifier in the file.所以需要为在文件中不用作标识符的
define
选择一个名称。 Commonly the define reflects the file name:通常定义反映文件名:
#ifndef NODE_H
#define NODE_H
struct node
{
int datum;
struct node * next;
};
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.