假设我有以下内容
struct MyType { long a, b, c; char buffer[remainder] }
我想做类似的事情char buffer[4096 - offsetof(MyType, buffer)]
但是好像是违法的
最佳答案
你可以做:
struct ABC {long a,b,c; }
struct MyType : ABC {char buffer[4096-sizeof(ABC)];};
static_assert(sizeof(MyType)==4096,"!");
关于c++ - 如何在编译时获得 'fill up' 大小的余数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64094754/