8711 views|4 replies

525

Posts

235

Resources
The OP
 

C language structure pointer definition problem help [Copy link]

Recently, I was debugging an Aurix TC275 controller. I defined a linked list in the program. The program is as follows: typedef struct { char *name; NODEPTR nextone; } *NODEPTR; During the compilation process, the compiler reported an error, prompting "Error, cannot use typedef type before defining it". Can't structure elements in C language contain pointers to themselves?


This post is from MCU

Latest reply

Come here to learn, take a look at the teachers’ answers, and work hard together! ! ! ! !  Details Published on 2024-4-18 21:17
Personal signature爱电子,爱生活
 

6040

Posts

204

Resources
2
 
This post was last edited by lcofjp on 2018-11-14 09:18 typedef struct NODE { char *name; NODE *nextone; } *NODEPTR; You can only define it this way, define it first and then use it
This post is from MCU
 
 

4005

Posts

0

Resources
3
 
Just change it to address type, and use (NODE *)
This post is from MCU
 
 
 

6063

Posts

4

Resources
4
 
Typedef is a keyword in C language, which is used to define a new name for a data type. The data types here include internal data types (int, char, etc.) and user-defined data types (struct, etc.). There are generally two purposes for using typedef in programming. One is to give the variable a new name that is easy to remember and has a clear meaning, and the other is to simplify some more complex type declarations. typedef struct { char *name; NODEPTR nextone; } NODE; Here, a new name is declared for this structure, which is easy to use later. NODE NODES, *NODESPTR; Define a structure of type NODE and a pointer. NODESPTR = &NODES; Assign the address of the structure to the pointer for easy operation.
This post is from MCU
 
 
 

413

Posts

0

Resources
5
 
Come here to learn, take a look at the teachers’ answers, and work hard together! ! ! ! !
This post is from MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list