Jey*_*ram 2 c struct linux-kernel
虽然在这里引用内核代码,但是struct page;没有成员定义(我猜这不是前向声明).
但是这篇文章中接受的答案是不允许的.
然后我试了一个样本,
#include <stdio.h>
struct page;
struct arm_vmregion
{
unsigned long vm_start;
unsigned long vm_end;
struct page *vm_pages;
int vm_active;
const void *caller;
};
int main()
{
struct arm_vmregion aa;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它编译成功
empty_struct.c: In function ‘main’:
empty_struct.c:15:22: warning: unused variable ‘aa’ [-Wunused-variable]
Run Code Online (Sandbox Code Playgroud)
请在这方面澄清一下.
空结构与前向声明不同 - 空结构将具有大括号,并且不合法.前瞻性声明当然可以.
struct foo; // forward declaration - OK
struct bar { // empty struct - invalid
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
159 次 |
| 最近记录: |