当前位置: 代码迷 >> 综合 >> container_of 报出 warning: initialization from incompatible pointer type 解决办法
  详细解决方案

container_of 报出 warning: initialization from incompatible pointer type 解决办法

热度:64   发布时间:2024-01-17 08:12:34.0

调试input 设备某sensor时候遇到一个有关container_of 报出 warning: initialization from incompatible pointer type 的警告。


这一切都是struct delayed_work work;惹的祸!


解决办法:

struct pcap_ts *pcap_ts = container_of(work, struct pcap_ts, work);


修改成


struct delayed_work *dw = container_of(work, struct delayed_work, work);
struct pcap_ts *pcap_ts = container_of(dw, struct pcap_ts, work);

或者

struct pcap_ts *pcap_ts = container_of(work, struct pcap_ts, work.work);

  相关解决方案