Labels in struct
tcak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 31 08:04:33 PST 2015
I do not have a big example in the end to show, but is there any
way to put labels into struct definitions?
struct CommunicationMessage{
char[2] signature;
mainData:
int info1;
int info2;
extraData:
ushort checksum;
content:
}
Example I defined something like above. I am using it as a base
structure, and don't know how long the content of message will
be. But I know that it will be at the end. I could use that
"content" label to find out about end of struct. But
unfortunately, it doesn't seem like it is supported.
I could say "void* endOfStruct = &struct + sizeof(struct)", but
then struct wouldn't be self explanatory with that content label
at the end.
More information about the Digitalmars-d-learn
mailing list