This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

armcc

Note: This was originally posted on 5th April 2013 at http://forums.arm.com

Is there a compiler option or pragma that allows me to see "padding" in c structure?  

typedef struct st
{
  char a;
  int  b;
} mytype; Basically, say I have above defined struct then I wish to known how compiler pads it.

list file does not seem  to provide the needed details. 

--diag_warning=1301
--diag_warning=2530

I tried above options, it shows warning when ever the compiler pads but the issue is i still do
not get how many bytes and where the padding is applied in the structure.

is there a easy way to get those two details ?
  • Note: This was originally posted on 9th April 2013 at http://forums.arm.com

    thanks for sharing additional information.

    @scott:   your suggested idea is not feasible as i am dealing with structures that are huge i.e., size is in 100s of KBs with many types of data types [size="2"]used in struct 
    [/size]

    @archie:  i tried using "--remarks" it still does not help as it does not provide padding size and also the place where it is padding.  below is the compile log

    C:\c>armcc  --remarks 1.c
    "1.c", line 3: #1301-D: padding inserted in struct st
    "1.c", line 3: #2530-D: padding added to end of struct st
    "1.c", line 14: #181-D: argument is incompatible with corresponding format string conversion
      printf ("sizeof (me) = %d \n",sizeof(me));
                                 ^
    "1.c", line 16: Warning:  #1-D: last line of file ends without a newline
      }
       ^
    1.c: 1 warning, 0 errors

    C:\c>

    recently i tried "fromelf" with option  "--expandarrays" and even that is not helping me.
  • Note: This was originally posted on 8th April 2013 at http://forums.arm.com

    I don't think there is a way to get the compiler to be more specific about the padding. The structure layout rules are in section 4 of the ABI http://infocenter.ar...042e/index.html.  You could manually add 'char dummy1;' members until the padding warnings go away and then you'll know that you've identified all of the padding.