A stream of chars are sent out to a communication device. For readability purposes, i wrote inidividual configurations as variables:
unsigned char a1;
unsigned char a2;
unsigned char a3;
unsigned char a4;
unsigned char a5;
std::string a6;
unsigned char a7;
unsigned char a8;
What is the best way to pack it into a variable tightly so that it's aligned perfectly?
Till now I've think of put everything into a struct
.
edit: struct
doesn't look like a viable option since struct
doesn't hold string
, and string is varying in size, although is a one time declared thing. Compiled in GCC
edit2: Gonna go with packed struct
method, but will convert the string
to a c_str
first. Until a better answer, this is the way to be.