gcc -Wpadded does not provide any warning

c, gcc

Solution

Seems that pack struct default is - 4. (`gcc -fpack-struct=4`) If it so - than this structure is already aligned. Because

char* - 4 or 8 bytes
int - 4 bytes

If you run this, you will have warning:

azat:~$ gcc -Wpadded -fpack-struct=8 -o test /tmp/test.c
/tmp/test.c:6:1: warning: padding struct size to alignment boundary [-Wpadded]

Because of the `int`.

Problem

I am trying to use gcc's -Wpadded option to know if gcc can help me in finding out whether a structure is padded or not. This is the following code. ``` #include<stdio.h> struct my { char *name; int age; } my_details; int main() { struct my person1; return 0; } ``` I complied the code using the following. `gcc -Wpadded alignment_demo.c`. It did not return any warnings. So is my structure not padded or I am missing something? `man gcc` however shows it supports an option called -Wpadded. Kindly help Thanks Chidambaram

Original source