Today, when defining struct, we found that the typedef struct and struct have some differences:
Structure is also a type of data. You can use Structure Variables. Therefore, like other types of variables, you must first define them when using structure variables.
The general format for defining structure variables is:
Struct structure name
{
Type variable name;
Type variable name;
...
}Structure Variable;
The structure name is the structure identifier, not the variable name.
Another common format is:
Typedef struct structure name
{
Type variable name;
Type variable name;
...
}Structure alias;
Note: In C, struct cannot contain functions. In C ++, struct is expanded to include functions.
GCC errors in programming:Expected specifier-qualifier-list before something. I checked the cause of the error on the Internet and explained it as follows:
When GCC is used, errors such as expected specifier-qualifier-list before… are often encountered. Specifiers refers to void, Char, struct Foo and other words; qualifiers refers to keywords such as const and volatile.This error occurs when a word is used before it is undefined,You can use typedef for definition and later. The error statement is as follows:
Typedef struct {int name [20]; int ID; Stu * Next; // error} Stu;Solution
Typedef struct {int name [20]; int ID; struct Stu * Next; // compiled} Stu;Defining struct with struct also has the same problem, and the solution is the same.