[英]Error : dereferencing pointer to incomplete type
我有一個結構定義為
50 struct nf_hook_state {
51 unsigned int hook;
52 int thresh;
53 u_int8_t pf;
54 struct net_device *in;
55 struct net_device *out;
56 struct sock *sk;
57 struct net *net;
58 struct list_head *hook_list;
59 int (*okfn)(struct net *, struct sock *, struct sk_buff *);
60
};
在我的代碼中,我試圖按如下方式訪問它:
unsigned int
my_packet_pass_through_hook(void *priv,
struct sk_buff *skb,
const struct nf_hook_state *state)
{
switch(state->hook){
編譯時,它給了我錯誤:
error: dereferencing pointer to incomplete type ‘const struct nf_hook_state’ switch(state->hook){
有人可以建議我在這里做錯了什么嗎?
您需要#include
包含nf_hook_state
struct
的頭文件,否則編譯器在編譯該翻譯單元時不知道該struct
的布局。
如果它不在特定標頭中,那么是時候相應地重構您的代碼了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.