I'm already having problems understanding structs even with two books. Now I get one with "struct struct". What does that mean. This is actually part of a linux program I'm trying to convert to C for PIC processors.
Also I'm getting errors in this code that should work like "unable to resolve identifier 'usb_interface'" which usually means the variable is not assigned anywhere before use. In other structs the name of the struct is not defined anywhere either.

static struct usbtmc_device_data *usbtmc_devs[USBTMC_MINOR_NUMBERS];
// This array will hold the private data pointers of the instruments. It is
// used by the minor 0 driver to get access to the USB sessions to retrieve
// instrument information.

struct usbtmc_device_data {
    struct cdev cdev;
    int devno;
    struct usb_interface *intf;
    const struct usb_device_id *id;
    unsigned int bulk_in;
    unsigned int bulk_out;
    UINT8 bTag;
    struct usb_device *usb_dev;
    UINT8 eof;
    char __user *retry_buf;
    size_t retry_count;
    int timeout;
    UINT8 term_char_enabled;
    UINT8 term_char;
    int fread;
    int auto_abort;
    int add_nl_on_read;
    int rem_nl_on_write;
};

I don't see "struct struct", but there's "static struct". To understand that, you just need to understand 'static', which is a qualifier for variables. In this case, it limits the scope of the variable to the file it's defined in.

The "Unable to resolve identifier 'usb_interface'" error is due to not having defined the usb_interface struct. You're saying usbtmc_device_data has a usb_interface, but it doesn't know what that type is. If it's defined in the file, then you need to move it above the definition of struct usbtmc_device_data.

Good grief! I read "static struct" as "struct struct" in every case!

"usb_interface" on the other hand appears to be a struct from this portion of code. This instance of "usb_interface" has the same error.

struct usbtmc_device_data {
    struct cdev cdev;
    int devno;
    struct usb_interface *intf;
    const struct usb_device_id *id;
    unsigned int bulk_in;
    unsigned int bulk_out;
    UINT8 bTag;
    struct usb_device *usb_dev;
    UINT8 eof;
    char __user *retry_buf;
    size_t retry_count;
    int timeout;
    UINT8 term_char_enabled;
    UINT8 term_char;
    int fread;
    int auto_abort;
    int add_nl_on_read;
    int rem_nl_on_write;
};
This article has been dead for over six months. Start a new discussion instead.