Hi all, I am working with the TI TUSB3200, trying to modify their example code for our own USB device. USB requires many tables which start with a length byte. I would like to use the sizeof operator to calculate this for me, as shown here:
byte code rictest[] = { sizeof(rictest), 1, 2 };
warning C198: sizeof returns 0
The reason that sizeof doesn't do what you want is because the object you are requesting the size of isn't defined, yet. So, its size is unknown. If you change your code to the following:
byte code rictest[12] = { sizeof(rictest), 1, 2 };
Jon suggested "If you are creating the VID and PID tables for USB, you can create structs for each of these and then you may use the sizeof operator to initialize the VID or PID structure." Thanks for the suggestion Jon, but it is the mainly the configuration descriptor (which is huge, about 280 bytes), which I am concerned about. I am slowly coming to the conclusion that I will have to write a seperate program to dynamically generate a .c file and matching .h file.