I have a static array of structures:
struct CommandStruct
{
char* data;
unsigned ans_size;
};
static const CommandStruct commands[] =
{
{ "Some literal", 28 },
{ "Some other literal", 29 },
{ "Yet another literal", 8 },
};
And I want the strings to be 16-byte aligned. Is it possible to achieve it directly?
I might get away with defining each literal separately, like __declspec(align(16)) static const char some_command_id[] = "my literal"
, but that's a mess. I need all initialization in a single block of code.
With C++11, following may help: https://ideone.com/IDEdY0
And so you have:
Having browsed through boost a bit, I've managed to cook up something which just automates separate literals construction, (I also make enum of all the array's elements):