Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个像这样的结构:
struct spidev_data { int busy; int irq; };
我只想通过定义访问成员(如 spidev->busy ),所以我试试这个:
#define BUSY spidev->busy
但它不起作用......
有人可以告诉我该怎么做吗?
谢谢 !
你应该试试这个
spidev_data *spidev = /* ... new or malloc ... */; BUSY = 1;
但更优雅的是
#define BUSY(X) (X)->busy ... BUSY(spidev) = 1;
因为它不是专门针对某个对象的。