在c中定义一个结构
Defining a struct in c
我有这段代码
struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
{
struct atmel_tc *tc;
/* Iterate over the list elements */
list_for_each_entry(tc, &tc_list, node) {
/* Do something with tc */
}
[...]
}
这是来自内核源文件,我对C有点陌生,所以我无法理解
这一行 struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
到目前为止,我看到的结构被简单地声明为 struct atmel_tc
没有任何参数或 * ,我见过像
这样的用法
struct node {
int data;
struct node *next;
}*head;
其中 *head 是指向节点实例的指针。这里也发生了类似的事情吗?
你能解释一下这一行吗,或者指出一些类似语法的文档
struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
这表示 atmel_tc_alloc
是一个函数,它 returns 指向 struct atmel_tc
的指针,并将名为 block
的 unsigned
和 block
作为参数=15=] 称为 name
.
我有这段代码
struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
{
struct atmel_tc *tc;
/* Iterate over the list elements */
list_for_each_entry(tc, &tc_list, node) {
/* Do something with tc */
}
[...]
}
这是来自内核源文件,我对C有点陌生,所以我无法理解
这一行 struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
到目前为止,我看到的结构被简单地声明为 struct atmel_tc
没有任何参数或 * ,我见过像
struct node {
int data;
struct node *next;
}*head;
其中 *head 是指向节点实例的指针。这里也发生了类似的事情吗?
你能解释一下这一行吗,或者指出一些类似语法的文档
struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
这表示 atmel_tc_alloc
是一个函数,它 returns 指向 struct atmel_tc
的指针,并将名为 block
的 unsigned
和 block
作为参数=15=] 称为 name
.