<?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>GBuffer.net &#187; C++</title>
	<atom:link href="http://www.gbuffer.net/archives/tag/c/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gbuffer.net</link>
	<description>&#62; Sid’s data dump</description>
	<lastBuildDate>Thu, 06 Oct 2011 16:09:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>New demo on spherical harmonic lighting</title>
		<link>http://www.gbuffer.net/archives/317</link>
		<comments>http://www.gbuffer.net/archives/317#comments</comments>
		<pubDate>Sat, 08 Jan 2011 00:13:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[demos]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=317</guid>
		<description><![CDATA[Looks like this blog is now being updated bi-annually. The last year or so has been quite a busy time for me. I&#8217;ve been updating my core skills. One of my main targets was to get my head round to understanding a global illumination technique that everyone seems to love so much these days &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like this blog is now being updated bi-annually. The last year or so has been quite a busy time for me. I&#8217;ve been updating my core skills. One of my main targets was to get my head round to understanding a global illumination technique that everyone seems to love so much these days &#8211; spherical harmonic lighting. It took some time for me to get my head around the math, and even more time for me to find the spare time to make an implementation. <a href="/shlighting">Click here to go to the page</a> with details on the implementation and a link to the full source code. As with a lot of things, once I understood what was being done, it all looked quite simple and straight forward. With that being said, I must say I still can&#8217;t claim to be an expert on the subject, but as I time goes by I hope to continue to improve upon it as the need arises.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/317/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile time assertion</title>
		<link>http://www.gbuffer.net/archives/111</link>
		<comments>http://www.gbuffer.net/archives/111#comments</comments>
		<pubDate>Fri, 18 Jan 2008 01:30:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gbuffer.net/?p=111</guid>
		<description><![CDATA[Yesterday I finally found a use for compile time checking. I remembered reading this up in Andrei&#39;s book &#39;Modern C++ Design&#39;. So I got down to implementing it in VS.NET 2005. His code (code below) seemed to work well in theory, but knowing MS, that&#39;s as far it goes. template&#60;bool&#62; struct CompileTimeChecker { CompileTimeChecker(...); }; [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I finally found a use for compile time checking. I remembered reading this up in Andrei&#39;s book &#39;Modern C++ Design&#39;. So I got down to implementing it in VS.NET 2005.</p>
<p> His code (code below) seemed to work well in theory, but knowing MS, that&#39;s as far it goes. </p>
<pre class="brush: c++">
template&lt;bool&gt; struct CompileTimeChecker
{
     CompileTimeChecker(...);
};
template&lt;&gt; struct CompileTimeChecker&lt;false&gt; { };
#define STATIC_CHECK(expr, msg)
     {
          class ERROR_##msg {};
          (void)sizeof(CompileTimeChecker&lt;(expr) != 0&gt;((ERROR_##msg())));
     }
</pre>
<p>Turns out that MS VS.Net had some complaints about the code above&#8230;
<pre>error C2066: cast to function type is illegalerror C2070: &#39;CompileTimeChecker (main::ERROR_ONE_NOT_EQUAL_TO_ONE (__cdecl *)(void))&#39;: illegal sizeof operand</pre>
<p> At first I thought I’d take the easy way out and just throw an error using a <font color="#0000ff">#pragma</font>. But then that would beat the very purpose of the code being compiler independent. After some 30 mins of trial and error, managed to get the same code (code below) working with a few minor modifications. </p>
<pre class="brush: c++">
template&lt;bool&gt; struct CompileTimeChecker
{
     CompileTimeChecker(...){};
};

template&lt;&gt; struct CompileTimeChecker&lt;false&gt; { };

#define STATIC_CHECK(expr, msg)
{
     class ERROR_##msg {};
     ERROR_##msg y ;
     (void)sizeof(CompileTimeChecker&lt;(expr) != 0&gt;((y)));
}
</pre>
<p>Now calling something like&#8230; </p>
<pre class="brush: c++">
STATIC_CHECK(sizeof(char)&gt;sizeof(int), SIZEOF_CHAR_NOT_GT_SIZEOF_INT) ;
</pre>
<p>will result in a compile time error that looks something like this&#8230;
<pre>error C2440: &#39;&lt;function-style-cast&gt;&#39; : cannot convert from &#39;main::ERROR_SIZEOF_CHAR_NOT_GT_SIZEOF_INT&#39; to &#39;CompileTimeChecker&#39;&gt; No constructor could take the source type, or constructor overload resolution was ambiguous</pre>
<p> Until next time, happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gbuffer.net/archives/111/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

