I'm having trouble with -Wpadded using C11 and structs.
I already read the alignment of structure elements with _Alignas , and I looked in the clang docs and saw that it is now supported.
In addition, I am using a very new version of clang, which I recently created from the torso.
$ clang --version
clang version 3.3 (trunk 175473)
Target: x86_64-unknown-linux-gnu
Thread model: posix
The problem I am facing is this:
#include <stdlib.h>
#include <stdalign.h>
struct foo{
void* a;
int b;
};
int main() {
struct foo instance;
instance.a = NULL;
instance.b = 2;
return 0;
}
What throws me this warning:
$ clang -Weverything -std=c11 t.c
t.c:4:8: warning: padding size of 'struct foo' with 4 bytes to alignment boundary [-Wpadded]
struct foo{
^
1 warning generated.
Isn't that what for _Alignas? I tried putting it before the int declaration, for example:
struct foo{
void* a;
_Alignas(void*) int b;
};
But the same warning remains. I also tried putting _Alignas in different places, but to no avail. What am I missing here?
, , , , , . , C , .