Is there a way to declare space in a struct as unused / filler / pad, in such as way as to not have to provide an identifier?
For example,
Code:struct foo {
int . ; // just 4 bytes, padding for later, don't need it now
int myval ;
} ;
Printable View
Is there a way to declare space in a struct as unused / filler / pad, in such as way as to not have to provide an identifier?
For example,
Code:struct foo {
int . ; // just 4 bytes, padding for later, don't need it now
int myval ;
} ;
You can have unnamed bit-fields.
Though 99% of people will just say this and think no more of it.Code:#include<stdio.h>
#include<stdlib.h>
#include<stddef.h>
int main()
{
struct foo {
int : 32;
int myval;
} bar;
bar.myval = 42;
printf("%zd\n",offsetof(struct foo,myval));
return 0;
}
Code:struct foo {
int dummy;
int myval;
};