<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Bit-fields in C99</title>
	<atom:link href="http://blog.reverberate.org/2009/06/26/bit-fields-in-c99/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.reverberate.org/2009/06/26/bit-fields-in-c99/</link>
	<description>parsing, performance, minimalism with C99</description>
	<lastBuildDate>Mon, 06 Feb 2012 23:44:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Someone</title>
		<link>http://blog.reverberate.org/2009/06/26/bit-fields-in-c99/comment-page-1/#comment-1358</link>
		<dc:creator>Someone</dc:creator>
		<pubDate>Mon, 29 Jun 2009 20:09:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.reverberate.org/?p=168#comment-1358</guid>
		<description>&quot;struct foo {
  unsigned int a:1;
  unsigned int b:2;
}

â€¦will always be packed into a single byte. sizeof(struct foo) could be greater than 1, but you are guaranteed that a and b are in the same byte.&quot;

On the other hand, the way I read &quot;If insufï¬cient space remains, whether a bit-ï¬eld that does not ï¬t is put into the next unit or overlaps adjacent units is implementation-deï¬ned&quot; would mean that

&quot;struct foo {
  unsigned int a:7;
  unsigned int b:7;
  unsigned int c:2;
}

can take 3 bytes.
&lt;i&gt;Aside: the preview shows backslashes before every double-quote. I hope these will disappear after submitting this comment.&lt;/i&gt;</description>
		<content:encoded><![CDATA[<p>&#8220;struct foo {<br />
  unsigned int a:1;<br />
  unsigned int b:2;<br />
}</p>
<p>â€¦will always be packed into a single byte. sizeof(struct foo) could be greater than 1, but you are guaranteed that a and b are in the same byte.&#8221;</p>
<p>On the other hand, the way I read &#8220;If insufï¬cient space remains, whether a bit-ï¬eld that does not ï¬t is put into the next unit or overlaps adjacent units is implementation-deï¬ned&#8221; would mean that</p>
<p>&#8220;struct foo {<br />
  unsigned int a:7;<br />
  unsigned int b:7;<br />
  unsigned int c:2;<br />
}</p>
<p>can take 3 bytes.<br />
<i>Aside: the preview shows backslashes before every double-quote. I hope these will disappear after submitting this comment.</i></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>http://blog.reverberate.org/2009/06/26/bit-fields-in-c99/comment-page-1/#comment-1356</link>
		<dc:creator>Jeremy</dc:creator>
		<pubDate>Sat, 27 Jun 2009 19:43:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.reverberate.org/?p=168#comment-1356</guid>
		<description>This is similar to a technique that is often used for accessing bit-fields of a hardware addressable register.  Some interesting comments relating to this were posted at RegisterBits: http://www.registerbits.com/bit-field-struct-union-c-firmware .

It seems that there are various concerns wrt non-portability of this seemingly elegant technique.  Namely bit-field ordering, memory alignment, endianess, compiler dependency,...

If you don&#039;t need to make the structure fit with some memory mapped hardware, then it should be a lot less of a concern so long as same compiler packs/unpacks the struct.  Even if the same compiler is used, the structure may look different in memory for different processor endiannesses.  Any serialization or tx/rx of the structure could cause issues too, I suppose (network ordering).</description>
		<content:encoded><![CDATA[<p>This is similar to a technique that is often used for accessing bit-fields of a hardware addressable register.  Some interesting comments relating to this were posted at RegisterBits: <a href="http://www.registerbits.com/bit-field-struct-union-c-firmware" rel="nofollow">http://www.registerbits.com/bit-field-struct-union-c-firmware</a> .</p>
<p>It seems that there are various concerns wrt non-portability of this seemingly elegant technique.  Namely bit-field ordering, memory alignment, endianess, compiler dependency,&#8230;</p>
<p>If you don&#8217;t need to make the structure fit with some memory mapped hardware, then it should be a lot less of a concern so long as same compiler packs/unpacks the struct.  Even if the same compiler is used, the structure may look different in memory for different processor endiannesses.  Any serialization or tx/rx of the structure could cause issues too, I suppose (network ordering).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

