19/05/14 21:12:50.85 8soz04JH0.net
>>512
不格好だけどこれでいけるよ
全部プリプロセッサで処理できて、構造体サイズは100バイト固定になる。
予想を超えてサイズを突き破った場合は別構造体作るしかないね。
#include <stddef.h>
struct inner_foo {
int a;
char buf[];
};
#define MAX_STRUCT_SIZE 100
#define BUF_SIZE (MAX_STRUCT_SIZE - offsetof(struct inner_foo, buf))
struct foo {
int a;
double b;
char buf[BUF_SIZE];
};