<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sizeof return in a structure</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/18998/sizeof-return-in-a-structure</link><description> Hi: 
 
I defined the following structure: 
 
 
struct ethernet_hdr {
 char destination[6];
 char source[6];
 unsigned short protocol;
};
 
 
consisting on 14 bytes. When I use 
sizeof(struct ethernet_hdr) I get 16 bytes and not 14. 
This would be a memory</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Sizeof return in a structure</title><link>https://community.arm.com/thread/87257?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2005 17:39:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:180eec55-bbce-4850-ba13-d249bd150050</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;typically an embedded compiler will support a pragma or option of some sort to declare a structure as &amp;#39;packed&amp;#39;&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
In fact, I think just about any compiler will support this - Borland C++ Builder certainly does, and I think MSVC does too.&lt;br /&gt;
&lt;br /&gt;
There&amp;#39;s no avoiding it, though - your&amp;#39;re going to have to &lt;b&gt;read the &lt;i&gt;Manual&lt;/i&gt;&lt;/b&gt; to find out for sure!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sizeof return in a structure</title><link>https://community.arm.com/thread/44191?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2005 15:45:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8d31bcc8-cbab-4cc2-9238-148d483d9be2</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;Sounds like it, yes.&lt;br /&gt;
&lt;br /&gt;
Compilers are allowed to pad structures for alignment.  I don&amp;#39;t use the Keil ARM tools, but typically an embedded compiler will support a pragma or option of some sort to declare a structure as &amp;quot;packed&amp;quot;, without any padding.  The GCC version is &amp;quot;-fpack-struct&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>