<?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; programming</title>
	<atom:link href="http://ejohansson.se/categories/programming/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>C++Next</title>
		<link>http://ejohansson.se/archives/2009/10/30/cpp-next/</link>
		<comments>http://ejohansson.se/archives/2009/10/30/cpp-next/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 19:41:46 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://ejohansson.se/?p=290</guid>
		<description><![CDATA[Found a very interesting C++ site the other day: C++Next. I highly recommend it if you&#8217;re interested in &#8220;the next generation of C++&#8221;. 
]]></description>
			<content:encoded><![CDATA[<p>Found a very interesting C++ site the other day: <a href="http://cpp-next.com/">C++Next</a>. I highly recommend it if you&#8217;re interested in &#8220;the next generation of C++&#8221;. </p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2009/10/30/cpp-next/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strip trailing whitespace in&#160;emacs</title>
		<link>http://ejohansson.se/archives/2008/08/26/strip-trailing-whitespace-in-emacs/</link>
		<comments>http://ejohansson.se/archives/2008/08/26/strip-trailing-whitespace-in-emacs/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 22:13:48 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://ejohansson.se/?p=195</guid>
		<description><![CDATA[Just installed WP-Syntax, a WordPress plugin for highlighting code. The first test will be this short elisp code I wrote to strip trailing whitespace from all lines in a file.

&#40;defun strip-trailing-ws &#40;&#41;
  &#34;Strip trailing whitespace from all lines&#34;
  &#40;interactive&#41;
  &#40;let &#40;&#40;cur &#40;point-marker&#41;&#41;&#41;
    &#40;goto-char &#40;point-min&#41;&#41;
    &#40;while &#40;re-search-forward [...]]]></description>
			<content:encoded><![CDATA[<p>Just installed <a title="WP-Syntax" href="http://wordpress.org/extend/plugins/wp-syntax/">WP-Syntax</a>, a WordPress plugin for highlighting code. The first test will be this short elisp code I wrote to strip trailing whitespace from all lines in a file.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> strip-trailing-ws <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #ff0000;">&quot;Strip trailing whitespace from all lines&quot;</span>
  <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>cur <span style="color: #66cc66;">&#40;</span>point-marker<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>goto-char <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">min</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>while <span style="color: #66cc66;">&#40;</span>re-search-forward <span style="color: #ff0000;">&quot;[ <span style="color: #000099; font-weight: bold;">\t</span>]+$&quot;</span> <span style="color: #b1b100;">nil</span> t<span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&#40;</span>replace-match <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #b1b100;">nil</span> <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>goto-char <span style="color: #66cc66;">&#40;</span>marker-position cur<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2008/08/26/strip-trailing-whitespace-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>++git;</title>
		<link>http://ejohansson.se/archives/2007/12/31/git/</link>
		<comments>http://ejohansson.se/archives/2007/12/31/git/#comments</comments>
		<pubDate>Mon, 31 Dec 2007 12:07:41 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2007/12/31/git/</guid>
		<description><![CDATA[As all the other cool kids, I&#8217;ve also started experimenting with git, the version control system used by many, most notably the Linux kernel developers.
As a test I converted my program that enables the volume knob on Dell USB keyboards. You can find it on my gitweb site.
Also there is the selinux policy module I [...]]]></description>
			<content:encoded><![CDATA[<p>As all the other cool kids, I&#8217;ve also started experimenting with <a href="http://git.or.cz/">git</a>, the version control system used by many, most notably the Linux kernel developers.</p>
<p>As a test I converted my program that <a href="http://ejohansson.se/archives/2006/05/23/enable-dells-volume-knob-under-linux/">enables the volume knob</a> on Dell USB keyboards. You can find it on <a href="http://git.ejohansson.se/">my gitweb</a> site.</p>
<p>Also there is the selinux policy module I blogged about in my <a href="http://ejohansson.se/archives/2007/11/04/selinux-subversion-and-mod_svn/">previous post</a>, and a new one that I had to do to get gitweb to work. Getting gitweb to work also required the git repositories to be properly labelled:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">semanage fcontext <span style="color: #660033;">-a</span> <span style="color: #660033;">-t</span> httpd_sys_script_ro_t <span style="color: #ff0000;">'/home/git(/.*)?'</span>
restorecon <span style="color: #660033;">-Rv</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>git</pre></div></div>

<p>Some day I need to figure out the correct syntax for putting file contexts in the policy module.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2007/12/31/git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Qt programming in&#160;Lisp</title>
		<link>http://ejohansson.se/archives/2006/04/18/qt-programming-in-lisp/</link>
		<comments>http://ejohansson.se/archives/2006/04/18/qt-programming-in-lisp/#comments</comments>
		<pubDate>Tue, 18 Apr 2006 17:11:29 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2006/04/18/qt-programming-in-lisp/</guid>
		<description><![CDATA[We all know the following facts: Qt is good; Lisp is good. So when I found the Lisp Qt4 bindings I knew it had to be good. I have &#8211; of course &#8211; not tried it (yet), but I like the concept. And there&#8217;s nothing like judging by appearance. Plus, good + good must equal [...]]]></description>
			<content:encoded><![CDATA[<p>We all know the following facts: Qt is good; Lisp is good. So when I found the <a href="http://members.aon.at/lispolos/">Lisp Qt4 bindings</a> I knew it had to be good. I have &#8211; of course &#8211; not tried it (yet), but I like the concept. And there&#8217;s nothing like judging by appearance. Plus, good + good must equal good. Just look at milk and beer&#8230; or umm&#8230; *cough*</p>
<p>While on the subject, I have to remember to try <a href="http://developer.kde.org/language-bindings/ruby/index.html">Korundum</a> when I get back to Linköping.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2006/04/18/qt-programming-in-lisp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using booleans to document&#160;code</title>
		<link>http://ejohansson.se/archives/2006/04/09/using-booleans-to-document-code/</link>
		<comments>http://ejohansson.se/archives/2006/04/09/using-booleans-to-document-code/#comments</comments>
		<pubDate>Sun, 09 Apr 2006 16:12:09 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[qt]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2006/04/09/using-booleans-to-document-code/</guid>
		<description><![CDATA[Today I want to share a tip on how to write self-documenting code that I picked up from the book Code Complete 2 by Steve McConnell. I will do this be showing you some code I just wrote, but let us start with the actual tip.

Instead of merely testing a boolean expression, you can assign [...]]]></description>
			<content:encoded><![CDATA[<p>Today I want to share a tip on how to write self-documenting code that I picked up from the book <a href="http://www.amazon.com/gp/product/0735619670/">Code Complete 2</a> by Steve McConnell. I will do this be showing you some code I just wrote, but let us start with the actual tip.</p>
<blockquote cite="http://www.cc2e.com/" title="Steve McConnell"><p>
Instead of merely testing a boolean expression, you can assign the expression to a variable that makes the implication of the test unmistakable.
</p></blockquote>
<p>The following code was my first try, not employing the tip.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp-qt" style="font-family:monospace;"><span style="color: #0057AE;">void</span> CETabWidget<span style="color: #006E28;">::</span><span style="color: #2B74C7;">wheelEvent</span><span style="color: #006E28;">&#40;</span><span style="color: #22aadd;">QWheelEvent</span> <span style="color: #006E28;">*</span>e<span style="color: #006E28;">&#41;</span>
<span style="color: #006E28;">&#123;</span>
  <span style="color: #22aadd;">QTabBar</span> <span style="color: #006E28;">*</span>tabs <span style="color: #006E28;">=</span> tabBar<span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
  <span style="color: #000000; font-weight:bold;">if</span> <span style="color: #006E28;">&#40;</span>e<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&lt;</span> tabs<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">||</span> e<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&gt;</span> <span style="color: #006E28;">&#40;</span>tabs<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">+</span> tabs.<span style="color: #2B74C7;">height</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span>
    e<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">ignore</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
    return<span style="color: #006E28;">;</span>
  <span style="color: #006E28;">&#125;</span>
&nbsp;
  <span style="color: #888888;">// handle wheel event</span>
<span style="color: #006E28;">&#125;</span></pre></div></div>

<p>Even though I wrote the code myself, I have problems understanding it. And making sure it&#8217;s correct takes more than a quick glance. If you want to understand this code in six months, you have to add a comment. So let us take a look at the same code rewritten to use two extra booleans.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp-qt" style="font-family:monospace;"><span style="color: #0057AE;">void</span> CETabWidget<span style="color: #006E28;">::</span><span style="color: #2B74C7;">wheelEvent</span><span style="color: #006E28;">&#40;</span><span style="color: #22aadd;">QWheelEvent</span> <span style="color: #006E28;">*</span>e<span style="color: #006E28;">&#41;</span>
<span style="color: #006E28;">&#123;</span>
  <span style="color: #22aadd;">QTabBar</span> <span style="color: #006E28;">*</span>tabs <span style="color: #006E28;">=</span> tabBar<span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
  <span style="color: #0057AE;">const</span> <span style="color: #0057AE;">bool</span> cursorAboveTabBar <span style="color: #006E28;">=</span> <span style="color: #006E28;">&#40;</span>e<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&lt;</span> tabs<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
  <span style="color: #0057AE;">const</span> <span style="color: #0057AE;">bool</span> cursorBelowTabBar <span style="color: #006E28;">=</span> <span style="color: #006E28;">&#40;</span>e<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&gt;</span> <span style="color: #006E28;">&#40;</span>tabs<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">y</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">+</span> tabs<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">height</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
  <span style="color: #000000; font-weight:bold;">if</span> <span style="color: #006E28;">&#40;</span>cursorAboveTabBar <span style="color: #006E28;">||</span> cursorBelowTabBar<span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span>
    e<span style="color: #006E28;">-&gt;</span><span style="color: #2B74C7;">ignore</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
    return<span style="color: #006E28;">;</span>
  <span style="color: #006E28;">&#125;</span>
&nbsp;
  <span style="color: #888888;">// handle wheel event</span>
<span style="color: #006E28;">&#125;</span></pre></div></div>

<p>Now you can quickly figure out that the wheel event is only handled if the cursor is inside the tabBar. And it&#8217;s actually possible to take a quick look and be sure that the code is doing what it&#8217;s supposed to.</p>
<p>Of course, for this to be of any good, you need to give the boolean variables meaningful names. Naming them a and b wouldn&#8217;t help a bit.</p>
<p>The best thing with this approach? You don&#8217;t have to write comments and still get code that people can understand. Ah, the joy!</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2006/04/09/using-booleans-to-document-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Language&#160;protagonist</title>
		<link>http://ejohansson.se/archives/2006/04/07/language-protagonist/</link>
		<comments>http://ejohansson.se/archives/2006/04/07/language-protagonist/#comments</comments>
		<pubDate>Fri, 07 Apr 2006 15:33:37 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2006/04/07/language-protagonist/</guid>
		<description><![CDATA[
The use of &#8216;protagonist&#8217; in place of &#8216;proponent&#8217; has become common in the 20th century and may have been influenced by a misconception that the first syllable of the word represents the prefix pro- (ie. &#8216;favoring&#8217;) rather than proto-, meaning first (as opposed to deuter-, second, in deuteragonist, or tri-, third, in tritagonist). For example, [...]]]></description>
			<content:encoded><![CDATA[<blockquote cite="http://en.wikipedia.org/wiki/Protagonist" title="Wikipedia"><p>
The use of &#8216;protagonist&#8217; in place of &#8216;proponent&#8217; has become common in the 20th century and may have been influenced by a misconception that the first syllable of the word represents the prefix pro- (ie. &#8216;favoring&#8217;) rather than proto-, meaning first (as opposed to deuter-, second, in deuteragonist, or tri-, third, in tritagonist). For example, usage such as &#8220;He was an early protagonist of nuclear power&#8221; can be replaced by &#8216;advocate&#8217; or &#8216;proponent&#8217;.
</p></blockquote>
<p>So, now that you know that, go read this post about <a href="http://blogs.qtdeveloper.net/archives/2006/04/07/would-you-implement-java-in-java/">language protagonist</a>. Great read.</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2006/04/07/language-protagonist/feed/</wfw:commentRss>
		<slash:comments>0</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>
		<item>
		<title>Midnight, grades and the need for&#160;awk</title>
		<link>http://ejohansson.se/archives/2006/03/18/midnight-grades-and-the-need-for-awk/</link>
		<comments>http://ejohansson.se/archives/2006/03/18/midnight-grades-and-the-need-for-awk/#comments</comments>
		<pubDate>Sat, 18 Mar 2006 17:56:52 +0000</pubDate>
		<dc:creator>Erik Johansson</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[awk]]></category>

		<guid isPermaLink="false">http://ejohansson.se/archives/2006/03/18/midnight-grades-and-the-need-for-awk/</guid>
		<description><![CDATA[At midnight, one day in the darkest period of November 2005, there was a programmer that needed to cool down a bit after having played floorball. Since this particular programmer for some reason, which to this day is still unknown, felt the need to play around a bit with awk, he created a script that [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_182" class="wp-caption alignright" style="width: 323px"><img src="http://files.ejohansson.se/wp-content/uploads/2008/08/floorball.png" alt="Floorball" title="Floorball" width="313" height="177" class="size-full wp-image-182" /><p class="wp-caption-text">Floorball</p></div>
<p>At midnight, one day in the darkest period of November 2005, there was a programmer that needed to cool down a bit after having played floorball. Since this particular programmer for some reason, which to this day is still unknown, felt the need to play around a bit with <a href="http://www.google.com/search?q=awk">awk</a>, he created a script that could calculate his average grade. Did he do this because he was a vain man, and wanted some confirmation? Or was it simply a good way to try awk? We&#8217;ll never know.</p>
<p>What we do know is that I&#8217;ve managed to get my hands on <a href="http://svn.ejohansson.se/repos/src/misc/awk/grade.awk">the script</a> and have created a page where all students at <a href="http://www.liu.se/">Linköping&#8217;s University</a> may <a href="http://ejohansson.se/grades.php">calculate their average grade</a>. It might even work for other universities, but that&#8217;s untested.</p>
<p>So if you want to know your average grade, <a href="http://ejohansson.se/grades.php">try it out</a>. In addition to your average grade you&#8217;ll also get your weighted average grade. If it for some reason doesn&#8217;t work for you, please let me know.</p>
<p><strong>Note 1:</strong> No, I&#8217;m not saving your grades when you submitt. If I ever wanted to see the grades of someone else, I&#8217;d ask or use my rights and get them directly from the school. All grades in Sweden are public you know. If you don&#8217;t trust me, RTFS (if you don&#8217;t know RTFS, <a href="http://www.google.com/search?q=RTFM">google for RTFM</a> and replace Manual with Source).</p>
<p><strong>Note 2:</strong> No, I will not publish my average. If it&#8217;s that interesting to you, the grades are public you know.</p>
<p>Then, what about that poor programmer? Well, not much is know about his whereabouts these days. But you will be pleased to hear that he has left the land of awk and moved on to do greater good in another programming language.</p>
<p>May the source be with you Luke!</p>
]]></content:encoded>
			<wfw:commentRss>http://ejohansson.se/archives/2006/03/18/midnight-grades-and-the-need-for-awk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
