<?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>C | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Fri, 23 May 2025 09:24:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>C | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Why I hate Assembly language&#8230;</title>
		<link>https://learncgames.com/why-i-hate-assembly-language/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-i-hate-assembly-language</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 29 Jun 2022 16:05:16 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[assembly language]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3060</guid>

					<description><![CDATA[<p>I spent several years in the 1980s programming games. I have a memory of 26 year old me sat hunched over a computer late at night back in 1985. I was working a 60-70 hour week as a partner in a games company. My current game was an American Civil War tactical wargame called Johnny [&#8230;]</p>
The post <a href="https://learncgames.com/why-i-hate-assembly-language/">Why I hate Assembly language…</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:52,&quot;href&quot;:&quot;http:\/\/www.6502.org\/source\/floats\/wozfp1.txt&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250822133323\/http:\/\/6502.org\/source\/floats\/wozfp1.txt&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:26:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 00:11:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 16:00:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 15:48:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 23:35:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 15:24:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-01 07:16:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-04 23:07:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 14:54:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 22:46:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 06:36:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-18 14:28:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-21 22:16:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 22:55:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-28 13:54:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 16:40:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-04 05:36:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-07 13:27:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 13:19:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 02:29:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 13:01:13&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-22 01:34:38&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-22 01:34:38&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:53,&quot;href&quot;:&quot;https:\/\/sites.google.com\/site\/6502asembly\/6502-instruction-set\/lda&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20221026080740\/https:\/\/sites.google.com\/site\/6502asembly\/6502-instruction-set\/lda&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:26:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-10 03:35:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 16:00:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 07:50:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 23:38:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-25 07:25:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 23:17:14&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-04 15:07:35&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-08 03:11:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-11 14:47:27&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-14 22:37:34&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-18 06:28:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-21 14:17:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-24 22:06:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-28 13:54:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-31 21:43:08&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-04 05:36:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-07 13:27:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 18:59:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 05:11:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-18 13:01:17&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-22 01:34:44&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-22 01:34:44&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:54,&quot;href&quot;:&quot;https:\/\/github.com\/wardog1uk\/mikro&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250306135453\/https:\/\/github.com\/wardog1uk\/mikro&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:28:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 03:35:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 16:00:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 07:50:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-20 23:38:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 23:26:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 15:18:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-04 07:08:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 22:57:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 14:47:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-14 22:37:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-18 06:28:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-21 14:17:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 22:06:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-28 13:54:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 16:40:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-04 05:36:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-07 13:27:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 05:21:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 13:12:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-17 21:02:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 12:56:57&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 12:56:57&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img fetchpriority="high" decoding="async" class="alignleft size-full wp-image-3062" src="https://learncgames.com/wp-content/uploads/2022/06/6502_assembler.png" alt="6502 assembler listing" width="573" height="506" srcset="https://learncgames.com/wp-content/uploads/2022/06/6502_assembler.png 573w, https://learncgames.com/wp-content/uploads/2022/06/6502_assembler-300x265.png 300w" sizes="(max-width: 573px) 100vw, 573px" />I spent several years in the 1980s programming games.</p>
<p>I have a memory of 26 year old me sat hunched over a computer late at night back in 1985. I was working a 60-70 hour week as a partner in a games company. My current game was an American Civil War tactical wargame called <strong>Johnny Reb II</strong>. I was struggling with some &#8216;artificial intelligence&#8217; code for the attackers (Confederate troops) to cross a bridge over a river. On the other side the defenders (Union) were trying to defend the bridge.</p>
<p><img decoding="async" class="alignleft size-full wp-image-3065" src="https://learncgames.com/wp-content/uploads/2022/06/johnnyRebII.png" alt="Johnny Reb II" width="284" height="177" /></p>
<p>Artificial Intelligence in games is a completely different thing from ML and Data Science nowadays. Back then it was just a control algorithm for troops reacting to the presence of enemy troops and working out the best routes, targets to attack, whether to retreat and so on.</p>
<p>What made it worse was that the whole thing was written in 6502 assembly language (and later converted to Z80). Back then you had two choices: Basic which was to be honest slow and clunky for writing games or assembly language. If I was doing it now, without a moments hesitation I&#8217;d program it in C. But C compilers for 6502 didn&#8217;t exist back then.</p>
<h3>The Problem with assembly language</h3>
<p>The problem with assembly language is<strong> (a) it&#8217;s slow to write.</strong> You can write 10 lines of C in the same time as ten lines of assembly code. Those ten lines of C will do far more than ten lines of assembly code. In 6502 all you are doing is moving values between registers or register &lt;&gt; memory. Maybe add a number or increment one of the three available registers A, X or Y. These were all 8-bit registers so you couldn&#8217;t even index easily through 64-bit memory. To do 16-bit indexing you stored the 16-bit address in two successive page-0 locations (addresses 0-255) and then used Y as an 8-bit index. You could do the same in page 0- memory with the X register.</p>
<p><strong>(b). It takes a lot of code to do anything in assembly language</strong>. You want floating point arithmetic in 6502? <a title="Link to Steve Wozniak source code for 6502 floating point routines" href="http://www.6502.org/source/floats/wozfp1.txt" target="_blank" rel="noopener">Take a look</a>.  I think Steve Wozniak wrote those for the Apple I/II. What we take for granted in languages like C# or Java or JavaScript is code for high level data structures like dictionaries. I&#8217;m sure it could be done but it takes a fair bit of programming. You don&#8217;t have those in assembly language; all you have to use is simple and not very long arrays.</p>
<p><em> In C# I wrote a program to read a 46 MB text file and produce a sorted count of all words in the file.  It used a Dictionary, took me 30 minutes to write and it ran in 5 seconds.  It would take weeks to do the same in assembler. </em></p>
<p>6502 Page 0 locations were valuable because they made your code both shorter and faster.</p>
<p>I wrote a cross-assembler for 6502 in Z80 as a way to learn Z80. Assemblers use labels (<em>L20, L30, L31 etc. in the screenshot</em>) and I needed a way to hold them efficiently in memory. I ended up with a 26 x 26 index table of 2 byte pointers. If you had a label &#8216;ROUTE&#8217; then there would be a pointer to a chain at the location for [&#8216;R&#8217;][&#8216;O&#8217;]. Each entry in the chain was like this</p>
<ul>
<li>1 byte length of rest of label (i.e. 3 for &#8216;UTE&#8217;) &#8211; 0 marks the end of the chain.</li>
<li>3 bytes to hold &#8216;UTE&#8217;.</li>
<li>2 byte address value</li>
</ul>
<p>No need to hold the whole word as you know the first two letters. It also makes comparing a label against one in the table was faster because it only needed to match against <em>len(label)-2</em> characters.</p>
<p>So the next value in the chain would start after that or be a 0 for the end of the chain. Yes most of the index table might be empty (all 26x26x2= 1352 bytes) but every label in a chain used 2 bytes less than the full label text. So with more than 676 labels you saved memory. Searching for a label was just a matter of walking a chain. Labels were just addresses; so a location could hold a value like a count. You&#8217;d identify it with a label and use that label in 6502 instructions. No variables in assembler; it&#8217;s all addresses&#8230;</p>
<p>With 6502 you need to do two passes to generate code. If you have a label in the first page of memory (0-255) then instructions are only two bytes long and are faster to execute than the three byte instructions. So on the first pass you don&#8217;t know if a <a title="Link to 6502 LDA instruction" href="https://sites.google.com/site/6502asembly/6502-instruction-set/lda" target="_blank" rel="noopener">LDA label</a> will be 2 or 3 bytes long. After the first pass through though you do know now, so on the 2nd pass it can output the correct size instructions.</p>
<p>Programming in assembler means you have to write a lot of code and in the early days before I had a development machine that meant I had to save the source code to tape and compile it using a cartridge assembler. The CBM-64 could take cartridges and one of them stored assembly language in RAM just like Basic. If the game did something wrong then the CBM-64 would reset and you&#8217;d lose your source and have to reload it from the slow tape. Let&#8217;s hope you didn&#8217;t forget to save changes before you ran it. I spent a few hours gnashing my teeth over a persistent crash. I was calling a CLR routine when it should have been CLS! d&#8217;oh&#8230;</p>
<p>Note, from memory it was <a href="https://github.com/wardog1uk/mikro" target="_blank" rel="noopener">the Mikro cartridge assembler</a>. See screenshot below.</p>
<figure id="attachment_3063" aria-describedby="caption-attachment-3063" style="width: 384px" class="wp-caption alignleft"><img decoding="async" class="size-full wp-image-3063" src="https://learncgames.com/wp-content/uploads/2022/06/mikro-assemblert.png" alt="Miro assembler start up screen. " width="384" height="272" srcset="https://learncgames.com/wp-content/uploads/2022/06/mikro-assemblert.png 384w, https://learncgames.com/wp-content/uploads/2022/06/mikro-assemblert-300x213.png 300w" sizes="(max-width: 384px) 100vw, 384px" /><figcaption id="caption-attachment-3063" class="wp-caption-text">Mikro Assembler Startup From <a href="https://github.com/wardog1uk/mikro" target="_blank" rel="noopener">Github</a></figcaption></figure>
<h3>Jump Tables</h3>
<p>So a game back then might be 5,000 lines of code or longer. That&#8217;s quite a bit to hold in memory, given that you need space for the game machine code, sprites, graphics etc. as well. Plus it&#8217;s wasteful having to recompile the same code over and over again. My cross-assembler did 250 lines per second but divide that by two for the two passes.</p>
<p>So I split up long files into smaller ones and created a jump table at the start. There was no linker so the code was loaded into RAM at fixed addresses. If you had five subroutines in one file then there&#8217;d be five jumps at the start to the actual function. And the files that called those functions just had a block of five calls at the start.</p>
<p>That way you didn&#8217;t have to worry exactly where the function was located in RAM so long as that file was always loaded at the same address.</p>
<p>&nbsp;</p>
<h3>Switching to Development Machines</h3>
<p>It got easier when we switched to development machines. The CBM-64 had a parallel port as did the development machine (<em>Tatung Einstein-a CP/M computer</em>) so a little bit of handler code in the CBM-64 set up the CIA chip to wait for data sent down the parallel cable and put the code directly in RAM. It took no time to load the handler from tape after a crash and then send down the whole file.</p>
<p>Modern CPUs do all sort of optimizing tricks and that&#8217;s even before you use vectorization. Compiler writers know how to generate code that uses these tricks but it would take quite a while to learn them so you could use them in hand-written assembly.</p>
<h2>Conclusion</h2>
<p>Writing in assembler in the 80s was easy to learn. Nowadays I wouldn&#8217;t know where to start- the Intel and AMD CPUs have a lot of different chips in their families so there are variations in what instructions are available. Oh and don&#8217;t forget there&#8217;s ARM CPUs as well.</p>
<p>Writing in C (or even C++) is a lot easier to get into and I very much doubt if you&#8217;d get any better performance in writing things in assembly. Also, it would take a lot longer.</p>The post <a href="https://learncgames.com/why-i-hate-assembly-language/">Why I hate Assembly language…</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3060</post-id>	</item>
		<item>
		<title>A blog post worth reading</title>
		<link>https://learncgames.com/a-blog-post-worth-reading/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-blog-post-worth-reading</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 21 Nov 2020 00:00:25 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Notes]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1853</guid>

					<description><![CDATA[<p>A developer called Jakub &#8220;Jorengarenar&#8221; Łukasiewicz has posted a blog entry Best aspects of C language and I&#8217;m more than happy to link to it. It says much of what I think about C but expressed very nicely and its well worth the read. In his post he refers to a document Rationale for International [&#8230;]</p>
The post <a href="https://learncgames.com/a-blog-post-worth-reading/">A blog post worth reading</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:364,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/clker-free-vector-images-3736\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=33668&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260115073407\/https:\/\/pixabay.com\/users\/clker-free-vector-images-3736\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 14:32:17&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-13 05:49:38&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-22 03:03:33&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-05 11:50:18&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 04:39:29&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-04 09:14:15&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 21:47:52&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 06:41:23&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 07:35:08&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 18:41:38&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 18:41:38&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:365,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=33668&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 14:32:19&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-13 05:49:37&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-22 03:03:33&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-05 11:50:18&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 04:39:29&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-04 09:14:27&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 21:47:54&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-13 13:43:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-18 03:47:26&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 18:41:34&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 18:41:34&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:366,&quot;href&quot;:&quot;https:\/\/blog.joren.ga\/programming\/best-of-c&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20221208223521\/https:\/\/blog.joren.ga\/programming\/best-of-c&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 14:32:23&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-13 05:49:32&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-22 03:03:33&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-05 11:50:18&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-26 04:39:30&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-04 09:14:18&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-08 21:47:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-13 13:43:46&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-18 03:47:34&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-21 18:41:46&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 18:41:46&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:367,&quot;href&quot;:&quot;http:\/\/www.open-std.org\/jtc1\/sc22\/wg14\/www\/C99RationaleV5.10.pdf&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206143536\/https:\/\/www.open-std.org\/jtc1\/sc22\/wg14\/www\/C99RationaleV5.10.pdf&quot;,&quot;redirect_href&quot;:&quot;https:\/\/www.open-std.org\/jtc1\/sc22\/wg14\/www\/C99RationaleV5.10.pdf&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-07 16:23:56&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-22 03:03:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-05 11:50:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 04:39:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-04 09:14:25&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-08 21:47:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-13 13:43:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 03:47:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 18:41:44&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 18:41:44&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_1854" aria-describedby="caption-attachment-1854" style="width: 272px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-medium wp-image-1854" src="https://learncgames.com/wp-content/uploads/2020/11/monogram-33668_640-272x300.png" alt="Letter C" width="272" height="300" srcset="https://learncgames.com/wp-content/uploads/2020/11/monogram-33668_640-272x300.png 272w, https://learncgames.com/wp-content/uploads/2020/11/monogram-33668_640.png 580w" sizes="auto, (max-width: 272px) 100vw, 272px" /><figcaption id="caption-attachment-1854" class="wp-caption-text">Image by <a href="https://pixabay.com/users/clker-free-vector-images-3736/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=33668">Clker-Free-Vector-Images</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=33668">Pixabay</a></figcaption></figure>
<p>A developer called Jakub &#8220;Jorengarenar&#8221; Łukasiewicz has posted a blog entry <a title="Link to log entry on Best aspects of C" href="https://blog.joren.ga/programming/best-of-c" target="_blank" rel="noopener noreferrer">Best aspects of C language</a> and I&#8217;m more than happy to link to it. It says much of what I think about C but expressed very nicely and its well worth the read.</p>
<p>In his post he refers to a document <a title="Link to C Rationale PDF on open-std.org" href="http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf" target="_blank" rel="nofollow noopener noreferrer">Rationale for International Standard Programming Languages</a> C (PDF).  This is a 2003 document (<em>C doesn&#8217;t change very often</em>)  and not exactly a light read at a trifle over 200 pages long. It&#8217;s an insight and commentary into what C99 is about and also lists these five principles:</p>
<ul>
<li>Trust the programmer.</li>
<li>Don’t prevent the programmer from doing what needs to be done.</li>
<li>Keep the language small and simple.</li>
<li>Provide only one way to do an operation.</li>
<li>Make it fast, even if it is not guaranteed to be portable.</li>
</ul>
<p>If you are learning C this will provide you with explanations of why some things in C99 are what thy are. Like myself you will discover things that you didn&#8217;t know. For instance I didn&#8217;t know about <strong>long double</strong>. Or that in K &amp; R C(<em>Kernighan and Ritchie)</em> that all floating point arithmetic was done at double precision but that was relaxed in C89.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/a-blog-post-worth-reading/">A blog post worth reading</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1853</post-id>	</item>
		<item>
		<title>Slight change of pace</title>
		<link>https://learncgames.com/slight-change-of-pace/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=slight-change-of-pace</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 09 Jul 2020 23:00:07 +0000</pubDate>
				<category><![CDATA[Ebook]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[This website]]></category>
		<category><![CDATA[C]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=962</guid>

					<description><![CDATA[<p>I&#8217;ve managed one blog entry per day for the last 134 days but a change in side project (I was writing a book to be published, not an Ebook)  but that has to be delayed by at least a year because of an issue at the publisher. In fact I may just publish what I&#8217;ve [&#8230;]</p>
The post <a href="https://learncgames.com/slight-change-of-pace/">Slight change of pace</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:634,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/GDJ-1086657\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3846597&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:635,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3846597&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_963" aria-describedby="caption-attachment-963" style="width: 300px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-medium wp-image-963" src="https://learncgames.com/wp-content/uploads/2020/07/social-media-3846597_640-300x189.png" alt="Networking" width="300" height="189" srcset="https://learncgames.com/wp-content/uploads/2020/07/social-media-3846597_640-300x189.png 300w, https://learncgames.com/wp-content/uploads/2020/07/social-media-3846597_640.png 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-963" class="wp-caption-text">Image by <a href="https://pixabay.com/users/GDJ-1086657/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3846597">Gordon Johnson</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3846597">Pixabay</a></figcaption></figure>
<p>I&#8217;ve managed one blog entry per day for the last 134 days but a change in side project (I was writing a book to be published, not an Ebook)  but that has to be delayed by at least a year because of an issue at the publisher. In fact I may just publish what I&#8217;ve done as my 2nd Ebook.</p>
<p>I&#8217;m currently working on networking on a Raspberry Pi. Unfortunately it has to be in C# not C. Networking is a lot easier in C#- you have OOP, task parallel library (<em>far easier than threads</em>), thread pools,. concurrency with async/await and a lot more.  And I can use C# with .NET core or Mono on the Pi.</p>
<p>That said, I will still continue on with game development on the PI. I&#8217;ve got my Match Three game half done; I&#8217;m quite proud of it and want to get it finished. But I may switch to a slightly less frequent blog posting schedule&#8230;</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/slight-change-of-pace/">Slight change of pace</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">962</post-id>	</item>
		<item>
		<title>I&#8217;ve started on the C++ Windows eBook</title>
		<link>https://learncgames.com/ive-started-on-the-c-windows-ebook/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ive-started-on-the-c-windows-ebook</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 21 Apr 2020 23:00:21 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Ebook]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[game]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=434</guid>

					<description><![CDATA[<p>I made the mistake of starting by trying to convert the final version of Asteroid; all 2,200 lines of C into C++. It got very messy because I was trying to have all the moving objects (Player ship, asteroids, bullets, aliens ship) all based on a common ancestor class but then was trying to manipulate [&#8230;]</p>
The post <a href="https://learncgames.com/ive-started-on-the-c-windows-ebook/">I’ve started on the C++ Windows eBook</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-436" src="https://learncgames.com/wp-content/uploads/2020/04/codelisting-300x225.jpg" alt="C++ Code listing photo" width="300" height="225" srcset="https://learncgames.com/wp-content/uploads/2020/04/codelisting-300x225.jpg 300w, https://learncgames.com/wp-content/uploads/2020/04/codelisting.jpg 600w" sizes="auto, (max-width: 300px) 100vw, 300px" />I made the mistake of starting by trying to convert the final version of Asteroid; all 2,200 lines of C into C++.</p>
<p>It got very messy because I was trying to have all the moving objects (Player ship, asteroids, bullets, aliens ship) all based on a common ancestor class but then was trying to manipulate those instances of the ancestor class and downcast back from the ancestor instances and I don&#8217;t think you can in C++. Compiler errors galore!</p>
<p>It was the wrong approach and I wasn&#8217;t using virtual functions. So instead I&#8217;m doing it step by step, adding on new features. Much like the original C development in 13 different steps.</p>
<p>Here&#8217;s the slightly shorter asteroids.cpp:</p>
<pre><code class="language-cpp" data-line="">// Asteroids C++ 2020 Chapter 27
#include &quot;game.h&quot;

int main(int argc,char * args[])
{
	Game g;
	g.InitSetup();
	g.GameLoop();
	g.FinishOff();
    return 0;
} </code></pre>
<p>There are other classes used from Game. I haven&#8217;t put everything in one &#8220;God&#8221; class!</p>The post <a href="https://learncgames.com/ive-started-on-the-c-windows-ebook/">I’ve started on the C++ Windows eBook</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">434</post-id>	</item>
		<item>
		<title>Identifying a Linux system in code</title>
		<link>https://learncgames.com/identifying-a-linux-system-in-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=identifying-a-linux-system-in-code</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 18 Apr 2020 23:00:54 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[code]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=412</guid>

					<description><![CDATA[<p>Since I got asteroids running on a Raspberry Pi, I have decided I want to incorporate the temperature in the window caption when you switch it to debug mod by pressing Tab. Currently all that does is display position info on moving objects and bounding boxes. But if I include that code in, I want [&#8230;]</p>
The post <a href="https://learncgames.com/identifying-a-linux-system-in-code/">Identifying a Linux system in code</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:772,&quot;href&quot;:&quot;https:\/\/linux.die.net\/man\/1\/uname&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251128020850\/https:\/\/linux.die.net\/man\/1\/uname&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 18:26:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 06:16:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 12:00:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 19:52:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-04 00:38:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-08 03:25:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 18:43:55&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 20:18:19&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 20:18:19&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:773,&quot;href&quot;:&quot;https:\/\/stackoverflow.com\/questions\/3596310\/c-how-to-use-the-function-uname&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20241123064104\/https:\/\/stackoverflow.com\/questions\/3596310\/c-how-to-use-the-function-uname&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 18:26:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 06:16:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 12:00:28&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 19:52:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-04 00:38:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-08 03:25:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 18:43:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 20:18:20&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 20:18:20&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<p>Since I got asteroids running on a Raspberry Pi, I have decided I want to incorporate the temperature in the window caption when you switch it to debug mod by pressing Tab. Currently all that does is display position info on moving objects and bounding boxes.</p>
<p>But if I include that code in, I want to be sure that it only works when running on a Raspberry Pi. So I need some code to identify the system. A bit of digging and I discovered the Linux <a href="https://linux.die.net/man/1/uname" target="_blank" rel="noopener noreferrer">uname</a> command. That link goes to an online man page for uname.</p>
<p>If I run <em>uname -a</em> on my Ubuntu 18.04LTS I get this.</p>
<pre><code class="language-bash" data-line="">Linux david-Virtual-Machine 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>
<p>And on my PI.</p>
<pre><code class="language-bash" data-line="">Linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l GNU/Linux</code></pre>
<p>In fact the <em>uname -n</em> command gives <strong>david-Virtual-Machine</strong> on Ubuntu and <strong>raspberrypi</strong> on the PI. These are the names though names are often changeable and what if someone is running ubuntu on a PI? Yes it is a thing. But the <em>uname -m</em> identifies the CPU.  x86-64 on my Ubuntu and armv71 on the pi.</p>
<p>I did a bit of digging and found a C program on <a href="https://stackoverflow.com/questions/3596310/c-how-to-use-the-function-uname" target="_blank" rel="noopener noreferrer">stackoverflow</a> that will do the same as uname.</p>
<pre><code class="language-c" data-line="">#include 
#include 
#include 
#include &lt;sys/utsname.h&gt;

int main(void) {

   struct utsname buffer;

   errno = 0;
   if (uname(&amp;buffer) != 0) {
      perror(&quot;uname&quot;);
      exit(EXIT_FAILURE);
   }

   printf(&quot;system name = %s\n&quot;, buffer.sysname);
   printf(&quot;node name   = %s\n&quot;, buffer.nodename);
   printf(&quot;release     = %s\n&quot;, buffer.release);
   printf(&quot;version     = %s\n&quot;, buffer.version);
   printf(&quot;machine     = %s\n&quot;, buffer.machine);

   #ifdef _GNU_SOURCE
      printf(&quot;domain name = %s\n&quot;, buffer.domainname);
   #endif

   return EXIT_SUCCESS;
}</code></pre>
<p>And this is what it outputs on a PI.</p>
<pre><code class="language-bash" data-line="">
system name = Linux
node name   = raspberrypi
release     = 4.19.97-v7+
version     = #1294 SMP Thu Jan 30 13:15:58 GMT 2020
machine     = armv7l</code></pre>
<p>So that bit is easy to do. Next is getting the temperature, but that&#8217;s for another blog entry&#8230;</p>The post <a href="https://learncgames.com/identifying-a-linux-system-in-code/">Identifying a Linux system in code</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">412</post-id>	</item>
		<item>
		<title>That Clang C compilation</title>
		<link>https://learncgames.com/that-clang-c-compilation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=that-clang-c-compilation</link>
					<comments>https://learncgames.com/that-clang-c-compilation/#comments</comments>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 10 Mar 2020 00:00:37 +0000</pubDate>
				<category><![CDATA[Clang]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[guard]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=95</guid>

					<description><![CDATA[<p>I spent about five hours trying to get the timing code to compile before I got it compiling and working. Now I&#8217;m used to the concept of include guards in C. Those are the #ifndef that you see like this: #ifndef _timeh #include &#60;linux/time.h&#62; #define _timeh 1 #endif But in the hr_time.c file these include guards [&#8230;]</p>
The post <a href="https://learncgames.com/that-clang-c-compilation/">That Clang C compilation</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:14,&quot;href&quot;:&quot;https:\/\/github.com\/David-H-Bolton\/LearnCOnLinux&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250213114627\/https:\/\/github.com\/David-H-Bolton\/LearnCOnLinux&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 16:40:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 18:24:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 22:16:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-18 22:19:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-21 22:22:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 04:17:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 04:17:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 04:22:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 04:38:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 08:48:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 09:17:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 10:18:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-18 12:43:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-21 15:14:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-24 15:19:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-27 16:38:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-30 19:05:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 19:29:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 21:51:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 22:18:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 22:18:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 22:20:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 07:27:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 10:16:46&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 10:16:46&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p>I spent about five hours trying to get the timing code to compile before I got it compiling and working. Now I&#8217;m used to the concept of include guards in C. Those are the #ifndef that you see like this:</p>
<pre><code class="language-c" data-line="">#ifndef _timeh
  #include &lt;linux/time.h&gt;
  #define _timeh 1
#endif</code></pre>
<p>But in the <strong>hr_time.c </strong>file these include guards are on steroids. Not only did I need to include <strong>&lt;time.h&gt;</strong>, I also had to include <strong>&lt;linux/time.h&gt;</strong> but with a couple of extra #defines in there. It doesn&#8217;t seem right and wasn&#8217;t needed with the Windows version.  I&#8217;d welcome any comments on this.</p>
<pre><code class="language-c" data-line="">#ifndef _timeh
  #include &lt;linux/time.h&gt;
  #define __timespec_defined 1 
  #define __itimerspec_defined 1
  #include &lt;time.h&gt;
  #define _timeh 1
#endif</code></pre>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-98 alignleft" src="https://learncgames.com/wp-content/uploads/2020/03/sdldemo2-300x232.png" alt="The sdldemo program with timing whown in the window caption." width="300" height="232" srcset="https://learncgames.com/wp-content/uploads/2020/03/sdldemo2-300x232.png 300w, https://learncgames.com/wp-content/uploads/2020/03/sdldemo2.png 760w" sizes="auto, (max-width: 300px) 100vw, 300px" />Without these, I&#8217;d get compile errors like <em>__timespec redefined</em> errors.</p>
<pre><code class="language-c" data-line=""></code></pre>
<p>I&#8217;ve uploaded the source files and Visual Studio Code JSON files for this in the file asteroids_ch25.zip in the new repository for the <a href="https://github.com/David-H-Bolton/LearnCOnLinux" target="_blank" rel="noopener noreferrer">Learn C on Linux Ebook</a></p>
<pre><code class="language-c" data-line=""></code></pre>
<p>So feel free to try it. The only difference between this and the version shown in an earlier post is the time (in the window caption) to draw all 100,000 rectangles,  You&#8217;ll need to install SDL2 if you want to compile and run the program.</p>The post <a href="https://learncgames.com/that-clang-c-compilation/">That Clang C compilation</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://learncgames.com/that-clang-c-compilation/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">95</post-id>	</item>
		<item>
		<title>Learn C Games</title>
		<link>https://learncgames.com/about-this-site/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=about-this-site</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 29 Feb 2020 09:26:33 +0000</pubDate>
				<category><![CDATA[Ebook]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1</guid>

					<description><![CDATA[<p>This blog is about C and Games programming (in C mainly). There are now two ebooks written by David Bolton, author of the Learn C Games Programming for beginners EBook. This is the Windows version, with a Raspberry Pi/Linux one now out.   The first 20 chapters introduce and teach C programming with many examples. This [&#8230;]</p>
The post <a href="https://learncgames.com/about-this-site/">Learn C Games</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.amazon.co.uk/Learn-C-Games-Programming-Beginners-ebook/dp/B07MZG5H29"><img loading="lazy" decoding="async" class="size-medium wp-image-12 alignleft" src="https://learncgames.com/wp-content/uploads/2020/02/learn-c-bookcover-193x300.jpg" alt="Learn C Games Programming Book cover" width="193" height="300" srcset="https://learncgames.com/wp-content/uploads/2020/02/learn-c-bookcover-193x300.jpg 193w, https://learncgames.com/wp-content/uploads/2020/02/learn-c-bookcover.jpg 450w" sizes="auto, (max-width: 193px) 100vw, 193px" /></a>This blog is about C and Games programming (in C mainly). There are now two ebooks written by <a href="https://dhbolton.com" target="_blank" rel="noopener noreferrer">David Bolton</a>, author of the <a href="https://www.dhbolton.com/learn-c-games-programming-beginners.html">Learn C Games Programming for beginners EBook</a>. This is the Windows version, with a Raspberry Pi/Linux one now out.  </p>
<p>The first 20 chapters introduce and teach C programming with many examples. <a href="https://www.dropbox.com/s/kl3rb85g8yq59iu/asteroids.mp4?dl=0">This link</a> is to an .mp4 of the asteroids game from the book. It&#8217;s about 90 seconds long and demonstrates all of the features of the game. High score table, rotating asteroids (four sizes), sound, explosions, ship hyper-jump and shields.</p>
<p>The remaining 30 chapters (20 in the Linux/Raspberry PI) builds up to full source code, about 2,000 lines, in 13 stages and I explain how each feature works and is implemented.  All of the book&#8217;s source code is on <a href="https://github.com/David-H-Bolton/LearnC" target="_blank" rel="noopener noreferrer">Github</a>. (Windows) or (<a title="Link to Learn C on Linux on GitHub" href="https://github.com/David-H-Bolton/LearnCOnLinux" target="_blank" rel="noopener">Linux</a>). <a href="https://learncgames.com/more-about-me/" target="_blank" rel="noopener noreferrer">More about me</a>. Buy the Windows one on <a title="Buy this book on Amazon UK" href="https://www.amazon.co.uk/Learn-C-Games-Programming-Beginners-ebook/dp/B07MZG5H29" target="_blank" rel="noopener noreferrer">Amazon(UK)</a>, <a title="Buy this book on Amazon USA" href="https://www.amazon.com/Learn-C-Games-Programming-Beginners-ebook/dp/B07MZG5H29" target="_blank" rel="noopener noreferrer">Amazon(US) </a>or the <a title="Link to ebook on Amazon UK,." href="https://amzn.eu/d/87tHW3A" target="_blank" rel="noopener">Linux/Raspberry PI</a>. (UK). You can buy the book in other regions by changing the region in Amazon to your local one. </p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/about-this-site/">Learn C Games</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		<enclosure url="https://www.dropbox.com/s/kl3rb85g8yq59iu/asteroids.mp4?dl=0" length="0" type="video/mp4" />

		<post-id xmlns="com-wordpress:feed-additions:1">1</post-id>	</item>
	</channel>
</rss>
