c语言中结构体的声明?
在C 代码中经常看到 "struct xxx;" 这种代码, libusb.h中 的struct libusb_device来说, 如下面所示:
这是什么意? 只是一个声明吗? 但是在这个文件中根本找不到 struct libusb_device 的定义, 因为libusb.h文件include的都是系统标准的头文件, 不可能有这个结构体的定义啊, 求解释, 谢谢!
完整的libusb.h 文件在这里:liusb.h
回答:
我帮你吧源码都下下来了.....找到了定义的地方,这里应该是声明
文件:libusbi.h
struct libusb_device { /* lock protects refcnt, everything else is finalized at initialization
* time */
usbi_mutex_t lock;
int refcnt;
struct libusb_context *ctx;
uint8_t bus_number;
uint8_t port_number;
struct libusb_device* parent_dev;
uint8_t device_address;
uint8_t num_configurations;
enum libusb_speed speed;
struct list_head list;
unsigned long session_data;
struct libusb_device_descriptor device_descriptor;
int attached;
unsigned char os_priv
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
[] /* valid C99 code */
#else
[0] /* non-standard, but usually working code */
#endif
#if defined(OS_SUNOS)
__attribute__ ((aligned (8)));
#else
;
#endif
};
回答:
This is just called Forward declaration
refer this: http://en.cppreference.com/w/...
以上是 c语言中结构体的声明? 的全部内容, 来源链接: utcz.com/p/195405.html