<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ejohansson.se &#187; c</title>
	<atom:link href="http://ejohansson.se/tags/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://ejohansson.se</link>
	<description>Random bits about Linux, programming, computers and occasionally other stuff.</description>
	<lastBuildDate>Sun, 18 Apr 2010 20:23:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compiler&#160;bug</title>
		<link>http://ejohansson.se/archives/2010/03/14/compiler-bug/</link>
		<comments>http://ejohansson.se/archives/2010/03/14/compiler-bug/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 17:49:05 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[licq]]></category>

		<guid isPermaLink="false">http://ejohansson.se/?p=327</guid>
		<description><![CDATA[To see if Licq would build without warnings with gcc 4.5 I tried to build Licq trunk with the latest gcc-snapshot in Debian today. Three warnings were quickly fixed but a bigger problem was that the unit test hung; something which doesn&#8217;t happen with earlier gcc.
After some digging it turned out to be a problem [...]]]></description>
			<content:encoded><![CDATA[<p>To see if Licq would build without warnings with gcc 4.5 I tried to build <a href="http://licq.org/browser/trunk">Licq trunk</a> with the latest gcc-snapshot in Debian today. Three warnings were quickly fixed but a bigger problem was that the unit test hung; something which doesn&#8217;t happen with earlier gcc.</p>
<p>After some digging it turned out to be a problem with locking. A mutex was never unlocked when returning in the <a href="http://licq.org/browser/trunk/licq/src/plugins/pluginthread.cpp?rev=7096#L89">exception handler</a>. This was very strange as the unlocking should be done by the MutexLocker destructor.</p>
<p>I was able to reproduce the problem with a simple test program so I concluded that it was indeed a compiler bug and reported it: <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43365">Destructor not called when returning in exception handler</a>.</p>
<p>Not every day you get to find a compiler bug&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2010/03/14/compiler-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing all the pre defined gcc&#160;macros</title>
		<link>http://ejohansson.se/archives/2010/01/07/printing-all-the-pre-defined-gcc-macros/</link>
		<comments>http://ejohansson.se/archives/2010/01/07/printing-all-the-pre-defined-gcc-macros/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 08:14:12 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c]]></category>

		<guid isPermaLink="false">http://ejohansson.se/?p=317</guid>
		<description><![CDATA[Found this useful command on brain-dump.org. Posting it here for my own reference:

gcc -dM -E - &#60; /dev/null

]]></description>
			<content:encoded><![CDATA[<p>Found this useful command on <a href="http://www.brain-dump.org/blog/entry/107">brain-dump.org</a>. Posting it here for my own reference:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-dM</span> <span style="color: #660033;">-E</span> - <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2010/01/07/printing-all-the-pre-defined-gcc-macros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Dell&#8217;s volume knob under&#160;linux</title>
		<link>http://ejohansson.se/archives/2006/05/23/enable-dells-volume-knob-under-linux/</link>
		<comments>http://ejohansson.se/archives/2006/05/23/enable-dells-volume-knob-under-linux/#comments</comments>
		<pubDate>Mon, 22 May 2006 22:24:20 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[c]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2006/05/23/enable-dells-volume-knob-under-linux/</guid>
		<description><![CDATA[Last week wasn&#8217;t one of my most productive weeks. Instead of working on my thesis, I created a small utility to make it possible to use the volume knob on Dell&#8217;s Enhanced Multimedia USB Keyboard under Linux. Not because I needed it, but because it didn&#8217;t work (and my other option was writing).
Anyway, if you&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_130" class="wp-caption alignright" style="width: 210px"><img src="http://files.ejohansson.se/wp-content/uploads/2008/08/dell_keyboard.jpg" alt="Dell’s Enhanced Multimedia USB Keyboard" title="Dell’s Enhanced Multimedia USB Keyboard" width="200" height="200" class="size-full wp-image-130" /><p class="wp-caption-text">Dell’s Enhanced Multimedia USB Keyboard</p></div>
<p>Last week wasn&#8217;t one of my most productive weeks. Instead of working on my thesis, I created a small utility to make it possible to use the volume knob on <a href="http://accessories.us.dell.com/sna/productdetail.aspx?c=us&#038;l=en&#038;s=biz&#038;cs=555&#038;sku=310-6166">Dell&#8217;s Enhanced Multimedia USB Keyboard</a> under Linux. Not because I needed it, but because it didn&#8217;t work (and my other option was writing).</p>
<p><del>Anyway, if you&#8217;d like to check out the program (it&#8217;s named knob btw), you&#8217;ll find it on my self-entitled wiki <a href="http://wiki.ejohansson.se/index.php/Software/knob">WikiErik</a> (yeah I know, the name sucks. But that&#8217;s how far my imagination goes when it comes to names).</del></p>
<p><b>Update:</b><br />
As some of you have noticed, WikiErik is no longer available. But the code is still available. Point your browser to <a href="http://git.ejohansson.se/">git.ejohansson.se</a> and the project <a href="http://git.ejohansson.se/?p=dellknob.git;a=summary">dellknob.git</a>. Or clone it by running</p>
<pre>
git clone git://git.ejohansson.se/dellknob.git
</pre>
<p><b>Update 2:</b><br />
Added a <a href="http://git.ejohansson.se/?p=dellknob.git;a=blob;f=README;hb=HEAD">README</a> with the contents from WikiErik.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2006/05/23/enable-dells-volume-knob-under-linux/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Odd (and deprecated) g++&#160;extensions</title>
		<link>http://ejohansson.se/archives/2006/03/28/odd-and-deprecated-g-extensions/</link>
		<comments>http://ejohansson.se/archives/2006/03/28/odd-and-deprecated-g-extensions/#comments</comments>
		<pubDate>Tue, 28 Mar 2006 22:23:27 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2006/03/28/odd-and-deprecated-g-extensions/</guid>
		<description><![CDATA[I&#8217;ve been spending the evening reading about libstdc++ (mostly the documentation) and how to do stuff The Right Way (the documentation is actually interesting, you should at least take a look at it). Now I feel the need to share some stuff that&#8217;s a bit more odd then what you see in the documentation.
First: &#8220;the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been spending the evening reading about <a href="http://gcc.gnu.org/libstdc++/">libstdc++</a> (mostly the <a href="http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html">documentation</a>) and how to do stuff The Right Way (the documentation is actually interesting, you should at least take a look at it). Now I feel the need to share some stuff that&#8217;s a bit more odd then what you see in the documentation.</p>
<p>First: <a href="http://docs.freebsd.org/info/gcc/gcc.info.Naming_Results.html">&#8220;the named return value extension&#8221;</a>. The idea is to avoid creating a temporary variable that&#8217;s assigned a value and then returned by value, thus creating an unnecessary copy. A small example:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">std<span style="color: #008080;">::</span><span style="color: #007788;">list</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> foo<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> j<span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">return</span> l<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#123;</span>
  l.<span style="color: #007788;">push_back</span><span style="color: #008000;">&#40;</span>j<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>This example will create just one list and append j to that. Without this extension a local list needs to be created, j appended to that and the copy constructor invoked when returning. This extension is deprecated in g++ 3.3 and removed in g++ 4.0.</p>
<p>My other example is the <a href="http://docs.freebsd.org/info/gcc/gcc.info.Min_and_Max.html">&#8220;min and max operators&#8221;</a>. No, this is not about min and max macros nor the std::min and std::max functions. This is the min and max <strong>operators</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> min <span style="color: #339933;">=</span> x <span style="color: #339933;">&lt;?</span> y<span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> max <span style="color: #339933;">=</span> x <span style="color: #339933;">&gt;?</span> y<span style="color: #339933;">;</span></pre></div></div>

<p>There is of course also a short-hand version for assigning one of the variables the smallest (or biggest) value of the two.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">x <span style="color: #339933;">&lt;?=</span> y<span style="color: #339933;">;</span>
x <span style="color: #339933;">&gt;?=</span> y<span style="color: #339933;">;</span></pre></div></div>

<p>They are all deprecated in g++ 4.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2006/03/28/odd-and-deprecated-g-extensions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
