S
spacewrench
I'm working on a USB device framework for a microcontroller. USB
requires manipulating many descriptor structures that are variably-
sized. For example:
struct StringDescriptor {
unsigned len;
wchar_t data[0];
}
(That's simpler than a real USB StringDescriptor, but it shows the
essential feature, a variably-sized array of wchar_t's that contain
the string data.)
I would like to be able to declare these at compile time, and place
them in Flash if appropriate:
StringDescriptor might_be_modified( "Some String Value" );
const StringDescriptor cannot_be_modified( "Fixed String Value" );
Is there a clean way to declare StringDescriptor so that the
declarations are simple and don't involve malloc(), new() or a run-
time constructor invocation? All the code examples I've seen just
declare an array of bytes, which has no type safety and poor
readability.
Thanks,
requires manipulating many descriptor structures that are variably-
sized. For example:
struct StringDescriptor {
unsigned len;
wchar_t data[0];
}
(That's simpler than a real USB StringDescriptor, but it shows the
essential feature, a variably-sized array of wchar_t's that contain
the string data.)
I would like to be able to declare these at compile time, and place
them in Flash if appropriate:
StringDescriptor might_be_modified( "Some String Value" );
const StringDescriptor cannot_be_modified( "Fixed String Value" );
Is there a clean way to declare StringDescriptor so that the
declarations are simple and don't involve malloc(), new() or a run-
time constructor invocation? All the code examples I've seen just
declare an array of bytes, which has no type safety and poor
readability.
Thanks,