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
You could do something like...
#include <string.h> static unsigned char code descriptor [] = { 1,2,3,4,5,6,7 }; unsigned char xdata xdescriptor [1 + sizeof (descriptor)] = { sizeof (descriptor), }; void main (void) { memcpy (&xdescriptor[1], descriptor, sizeof (descriptor)); }