<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>The Rebertian Times &#187; book</title>
	<atom:link href="http://blog.rebertia.com/tag/book/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rebertia.com</link>
	<description>All my thoughts that are fit to blog. Which mostly consists of stuff about programming.</description>
	<lastBuildDate>Mon, 09 May 2011 20:44:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>C in a Nutshell in a Nutshell</title>
		<link>http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/</link>
		<comments>http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 22:12:19 +0000</pubDate>
		<dc:creator>Chris Rebert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[nutshell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://blog.rebertia.com/?p=133</guid>
		<description><![CDATA[I recently finished reading C in a Nutshell, which I highly recommend as an excellent C reference and tutorial to anyone with programming experience. I previously learned some MS Visual C++ at CyberCamps some years ago, but finding the language a bit clunky, I searched around the web, found Python and have been in love [...]]]></description>
			<content:encoded><![CDATA[<p>I recently finished reading <a href="http://www.amazon.com/C-Nutshell-OReilly-Peter-Prinz/dp/0596006977/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1238891376&amp;sr=8-1"><em>C in a Nutshell</em></a>, which I highly recommend as an excellent C reference and tutorial to anyone with programming experience. I previously learned some MS Visual C++ at CyberCamps some years ago, but finding the language a bit clunky, I searched around the web, found Python and have been in love with it ever since. But since every programmer should know (at least most of) C, and I had a C/Assembly course coming up, I resolved to learn C properly; hence the book. Anyway, here are my notes from it, both as a memo to myself and in the hope that others might find it mildly useful:</p>
<h1>Interesting trivia</h1>
<ul>
<li><code>index[array]</code> ≡ <code>array[index]</code> ≡  <code>*(array + index)</code></li>
<li>arguments to a function may be evaluated in <strong><em>any</em></strong> order by the compiler</li>
<li>The <code>signed</code>-ness of plain <code>char</code> is compiler-dependent</li>
</ul>
<h1><a href="http://en.wikipedia.org/wiki/C99">C99</a> Hotness</h1>
<ul>
<li>Boolean type introduced:</li>
</ul>
<pre class="brush:c">#include &lt;stdbool.h&gt;
bool a = true, b = false;</pre>
<ul>
<li><code>//</code>-comments formally allowed</li>
<li>declarations can go <strong><em>anywhere<span style="font-weight: normal;"><span style="font-style: normal;"> within a function; C89 forces you to declare <strong>everything</strong> at the </span>start<span style="font-style: normal;"> of the function</span></span></em></strong></li>
</ul>
<h1>Syntax</h1>
<pre class="brush:c">#include &lt;something_in_std_lib.h&gt;
#include "your_own_lib.h"
enum SomeEnum {A, B, C};
typedef someDeclaration newTypeAlias;</pre>
<ul>
<li><code>const</code> keyword, like Java&#8217;s <code>final</code></li>
<li><code>static</code> keyword means private to this source file, like C#&#8217;s <code>internal</code></li>
</ul>
<h1>Basics</h1>
<pre class="brush:c">int main(int argc, char * argv[])
char aStringVariable[length];</pre>
<ul>
<li><code>EXIT_SUCCESS</code>, <code>EXIT_FAILURE</code> defined in <code>stdlib.h</code></li>
</ul>
<h1>Function pointers</h1>
<pre class="brush:c">int foo(char);//declare function
int (*funcPtr)(char) = foo;
int result = funcPtr('a');//use func pointer</pre>
<h1>Objects</h1>
<h2>Defining</h2>
<pre class="brush:c">struct Foo
//unions use same syntax, just w/ different keyword
{
    int a;
    char b;
}</pre>
<h2>Using</h2>
<pre class="brush:c">/* C99: */ struct Foo bar = {.b = 'Q', .a = 42};
/* C89: */ struct Foo baz = {42, 'Q'};</pre>
<h1>Defining <a href="http://en.wikipedia.org/wiki/C_preprocessor">macros</a></h1>
<ul>
<li>Function-like macros: <code>#define foo(a,b) ((a)-(b))</code></li>
<li>The <code>##</code> operator within macros:
<ul>
<li>Given: <code>#define foo(x) MSG_##x</code></li>
</ul>
<ul>
<li>Then: <code>foo(A)</code> ≡ <code>MSG_A</code></li>
</ul>
</li>
<li>The <code>#</code> operator within macros &#8211; converts operand to string</li>
</ul>
<h1>Useful macros</h1>
<p><a href="http://en.wikipedia.org/wiki/Assertion_(computing)">Assertions</a>:</p>
<pre class="brush:c">#include &lt;assert.h&gt;
assert(booleanExpression);</pre>
<ul>
<li><code>#define NDEBUG</code> &#8211; disables asserts</li>
<li><code>#error "Message"</code> &#8211; causes compile error with given message</li>
<li>Conditional compilation: <code>#if</code>, <code>#elif</code>, <code>#else</code>, <code>#endif</code></li>
</ul>
<h1>Metadata macros</h1>
<ul>
<li><code>__func__</code> &#8211; name of current function</li>
<li><code>__LINE__</code> &#8211; current line number</li>
<li><code>__FILE__</code> &#8211; name of current file</li>
<li><code>__TIME__</code> &#8211; time of compilation</li>
<li><code>__DATE__</code> &#8211; date of compilation</li>
</ul>
<h1>Standards macros</h1>
<ul>
<li><code>__STDC__</code> &#8211; bool for whether compiler is C89-compliant</li>
<li><code>__STDC_VERSION__</code> &#8211; <code>199901L &gt;=</code> if C99-compliant</li>
<li><code>__STDC_IEC_559__</code> &#8211; bool for <a href="http://en.wikipedia.org/wiki/IEEE_754">IEEE-754</a> compliance</li>
</ul>
<h1><a href="http://en.wikipedia.org/wiki/C_standard_library">Stdlib</a> survey</h1>
<ul>
<li><code><a href="http://en.wikipedia.org/wiki/Stdlib.h">stdlib.h</a></code>: <code><a href="http://en.wikipedia.org/wiki/Malloc">malloc</a>()</code>, <code>free()</code>, array sorting, binary search, str-&gt;num conversion, random numbers</li>
<li><code><a href="http://en.wikipedia.org/wiki/Stddef.h">stddef.h</a></code>: defines <code><a href="http://en.wikipedia.org/wiki/Null_pointer">NULL</a></code>, <code><a href="http://en.wikipedia.org/wiki/Size_t">size_t</a></code></li>
<li><code><a href="http://en.wikipedia.org/wiki/String.h">string.h</a></code>: also includes general array/memory stuff</li>
<li><code><a href="http://en.wikipedia.org/wiki/Math.h">math.h</a></code>, <code><a href="http://en.wikipedia.org/wiki/Time.h">time.h</a></code>: speak for themselves</li>
<li><code><a href="http://en.wikipedia.org/wiki/Errno.h">errno.h</a></code>: defines <code>errno</code> global var</li>
<li><code><a href="http://en.wikipedia.org/wiki/Ctype.h">ctype.h</a></code>: ASCII character classification</li>
<li><code><a href="http://en.wikipedia.org/wiki/Fenv.h">fenv.h</a></code>: controls floating point rounding mode, etc [<strong>C99 only</strong>]</li>
<li><code><a href="http://en.wikipedia.org/wiki/Limits.h">limits.h</a></code>: limits of integer types</li>
<li><code><a href="http://en.wikipedia.org/wiki/Float.h">float.h</a></code>: describes properties of float representation</li>
<li>See also <a href="http://rebertia.com/wiki/C_Stdlib_Notes">my summary </a>of the essential parts of the stdlib</li>
</ul>
<h1><a href="http://en.wikipedia.org/wiki/GNU_Compiler_Collection">GCC</a> options</h1>
<ul>
<li><code>-o exec_name</code> (instead of <code>a.out</code>)</li>
<li><code>-Idir_name:other_dir_name</code> (places to also look for headers)</li>
<li><code>-fsyntax-only</code> (just check syntax)</li>
<li><code>-ansi</code> (use C89)</li>
<li><code>-std=c99</code> (use C99)</li>
<li><code>-Wall</code> (warn about a bunch of stuff)</li>
<li><code>-pedantic</code> (adhere pedantically to standard)</li>
<li><code>-Wextra</code> (warn about strange/pointless code)</li>
<li><code>-g</code> (add debug info)</li>
<li><code>-pg</code> (add profiling hooks)</li>
</ul>
<img src="http://blog.rebertia.com/?ak_action=api_record_view&id=133&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>&quot;Phrase from Nearest Book&quot; Meme</title>
		<link>http://blog.rebertia.com/2008/11/15/phrase-from-nearest-book-meme/</link>
		<comments>http://blog.rebertia.com/2008/11/15/phrase-from-nearest-book-meme/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 07:29:13 +0000</pubDate>
		<dc:creator>Chris Rebert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[meme]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://rebertia.wordpress.com/?p=28</guid>
		<description><![CDATA[Via a random blog on Planet Python: Grab the nearest book. Open it to page 56. Find the fifth sentence. Post the text of the sentence in your blog along with these instructions. Don’t dig for your favorite book, the cool book, or the intellectual one: pick the CLOSEST. Here&#8217;s my fairly boring quote from [...]]]></description>
			<content:encoded><![CDATA[<p>Via <a href="http://mcjeff.blogspot.com/2008/11/phrase-from-nearest-book-meme.html">a random blog on Planet Python</a>:</p>
<ul>
<li>Grab the nearest book.</li>
<li>Open it to page 56.</li>
<li>Find the fifth sentence.</li>
<li>Post the text of the sentence in your blog along with these instructions.</li>
<li>Don’t dig for your favorite book, the cool book, or the intellectual one: pick the CLOSEST.</li>
</ul>
<p>Here&#8217;s my fairly boring quote from <a title="RONR - Wikipedia" href="http://en.wikipedia.org/wiki/Robert%27s_Rules_of_Order">Robert&#8217;s Rules of Order Newly Revised &#8211; In Brief</a> (which beat out <a title="ANTLR Reference" href="http://www.pragprog.com/titles/tpantlr/the-definitive-antlr-reference">The Definitive ANTLR Reference</a> by mere inches):</p>
<blockquote><p>If the bylaws are silent on the method of appointing members of special committees, the method is typically set for that committee in the motion creating the committee.</p></blockquote>
<p><a href="http://en.wikipedia.org/wiki/Parliamentary_procedure">Parliamentary procedure</a> may be dry, but it is truly essential to running good meetings. I got this book just a few weeks ago using overnight shipping to prepare for the first <a href="http://as.ucsd.edu/">Associated Students</a> Council meeting I attended.</p>
<p>Let&#8217;s just hope I never have to move to <em>Object to the Consideration of a Question</em>.</p>
<p>P.S. The naming of the <em>Previous Question</em> motion is just plain confusing, history be damned. Thank goodness we just use &#8220;Call the Question&#8221; instead.</p>
<img src="http://blog.rebertia.com/?ak_action=api_record_view&id=28&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.rebertia.com/2008/11/15/phrase-from-nearest-book-meme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

