<?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>Clang | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/clang/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>Sun, 26 Mar 2023 08:51:51 +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>Clang | 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>New Linux Timing Code</title>
		<link>https://learncgames.com/new-linux-timing-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-linux-timing-code</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 26 Mar 2023 00:00:22 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Clang]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[timing]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3221</guid>

					<description><![CDATA[<p>For some time, I had a problem with my old Linux timing code. The units hr_time.h/c had to have the includes arranged in the right order and some flags set for it to compile. Plus it never seemed right having to do this in hr_time.h #include &#60;linux/time.h&#62; #define __timespec_defined 1 #define __itimerspec_defined 1 #define __timeval_defined [&#8230;]</p>
The post <a href="https://learncgames.com/new-linux-timing-code/">New Linux Timing 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;:30,&quot;href&quot;:&quot;https:\/\/solarianprogrammer.com\/2019\/04\/17\/c17-programming-measuring-execution-time-delaying-program&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251202052526\/https:\/\/solarianprogrammer.com\/2019\/04\/17\/c17-programming-measuring-execution-time-delaying-program\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:04:01&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-11 21:41:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-20 02:02:02&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 20:04:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 11:01:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 22:29:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 18:00:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 00:00:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 12:32:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-21 20:48:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 05:21:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 18:33:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 11:16:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 20:05:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 09:28:22&quot;,&quot;http_code&quot;:206},{&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;}]'></div>
<p><img fetchpriority="high" decoding="async" class="alignleft wp-image-3223 size-medium" src="https://learncgames.com/wp-content/uploads/2023/03/2yj6mbvj0sg-300x169.jpg" alt="silver and white round analog watch" width="300" height="169" srcset="https://learncgames.com/wp-content/uploads/2023/03/2yj6mbvj0sg-300x169.jpg 300w, https://learncgames.com/wp-content/uploads/2023/03/2yj6mbvj0sg-1024x576.jpg 1024w, https://learncgames.com/wp-content/uploads/2023/03/2yj6mbvj0sg-768x432.jpg 768w, https://learncgames.com/wp-content/uploads/2023/03/2yj6mbvj0sg-1536x864.jpg 1536w, https://learncgames.com/wp-content/uploads/2023/03/2yj6mbvj0sg.jpg 1600w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>For some time, I had a problem with my old Linux timing code. The units hr_time.h/c had to have the includes arranged in the right order and some flags set for it to compile. Plus it never seemed right having to do this in hr_time.h</p>
<pre><code class="language-c" data-line="">#include &lt;linux/time.h&gt;
#define __timespec_defined 1
#define __itimerspec_defined 1
#define __timeval_defined 1
</code></pre>
<p>But today I found some better code on this <a title="Link to entry on Solarianprogrammer.com" href="https://solarianprogrammer.com/2019/04/17/c17-programming-measuring-execution-time-delaying-program/" target="_blank" rel="nofollow noopener">Solarian</a>Programmer website and I&#8217;m always happy to give credit where it&#8217;s due. I&#8217;ve witched to using C17 which clang on Ubuntu (clang 14) and Raspberry Pi (clang 11) both seem to accept.</p>
<p>So now my hr_time.h looks like this:</p>
<p>hr_time.h</p>
<pre><code class="language-c" data-line="">#pragma once
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

void startTimer();
void stopTimer();
double diff();</code></pre>
<p>hr_time.c</p>
<pre><code class="language-c" data-line="">#include &quot;hr_time.h&quot;
#include &lt;time.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;

struct timespec start;
struct timespec end;

void startTimer() {
	if (timespec_get(&amp;start, TIME_UTC) != TIME_UTC) {
		printf(&quot;Error in calling timespec_get\n&quot;);
		exit(EXIT_FAILURE);
	}
};

void stopTimer() {
	if (timespec_get(&amp;end, TIME_UTC) != TIME_UTC) {
		printf(&quot;Error in calling timespec_get\n&quot;);
		exit(EXIT_FAILURE);
	}
};

double diff()
{
	return  (double)(end.tv_sec - start.tv_sec) + 
			((double)(end.tv_nsec - start.tv_nsec) / 1000000000L);
}</code></pre>
<p>I&#8217;m only ever using one timer, if you want to modify this to pass in a timer in the startTimer and stopTimer then it&#8217;s easy enough.</p>The post <a href="https://learncgames.com/new-linux-timing-code/">New Linux Timing 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">3221</post-id>	</item>
		<item>
		<title>Interesting gcc/clang extensions to C</title>
		<link>https://learncgames.com/interesting-gcc-clang-extensions-to-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=interesting-gcc-clang-extensions-to-c</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 18 Mar 2021 00:00:49 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Clang]]></category>
		<category><![CDATA[clang]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[gcc]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2903</guid>

					<description><![CDATA[<p>Both gcc and clang support extensions to C and while i normally try and make things I write about work on Windows (i.e. Visual Studio), these are useful enough that I thought they deserve a mention. Yes I know you can run gcc/clang on Windows using Cygwin or MinGW, but for various reasons I prefer [&#8230;]</p>
The post <a href="https://learncgames.com/interesting-gcc-clang-extensions-to-c/">Interesting gcc/clang extensions to C</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignleft wp-image-2905 size-medium" src="https://learncgames.com/wp-content/uploads/2021/03/c-example-1-300x70.png" alt="C Example" width="300" height="70" srcset="https://learncgames.com/wp-content/uploads/2021/03/c-example-1-300x70.png 300w, https://learncgames.com/wp-content/uploads/2021/03/c-example-1.png 507w" sizes="(max-width: 300px) 100vw, 300px" />Both gcc and clang support extensions to C and while i normally try and make things I write about work on Windows (<em>i.e. Visual Studio</em>), these are useful enough that I thought they deserve a mention. Yes I know you can run gcc/clang on Windows using Cygwin or MinGW, but for various reasons I prefer Visual Studio.</p>
<p>You can add a constructor and destructor functions to a C program; the constructor function runs before main() and the destructor after main().</p>
<p>The syntax is not exactly clean or obvious (<em>those are double underscores before and after the word <strong>attribute</strong> like Python dunders!</em>) but I got this program to compile/run with clang 10 on Ubuntu as the screenshot shows.  Here&#8217;s a listing. I called the two functions ctor and dtor but you can use anything.</p>
<pre><code class="language-c" data-line="">#include &lt;stdio.h&gt;

__attribute__((constructor)) void ctor(void)
{
  printf(&quot;Constructor runs first\n&quot;);
}

__attribute__((destructor)) void dtor(void)
{
  printf(&quot;Destructor runs last\n&quot;);
}

int main() {
    printf(&quot;Main\n&quot;);
}</code></pre>
<p>The output  is:</p>
<pre>david@DavidPC:~/Projects/Examples$ ./ex1
Constructor runs first
Main
Destructor runs last</pre>The post <a href="https://learncgames.com/interesting-gcc-clang-extensions-to-c/">Interesting gcc/clang extensions to C</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">2903</post-id>	</item>
		<item>
		<title>Raspberry Pi 4 &#8211; Perfect for arcade quality games and development</title>
		<link>https://learncgames.com/raspberry-pi-4-perfect-for-arcade-quality-games-and-development/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=raspberry-pi-4-perfect-for-arcade-quality-games-and-development</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 25 Apr 2020 23:00:24 +0000</pubDate>
				<category><![CDATA[Clang]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[Visual Studio Code]]></category>
		<category><![CDATA[arcade]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=460</guid>

					<description><![CDATA[<p>I got my Pi 4 a week ago and have been doing experiments on it with my Asteroids game. If I disable the line of code that kills the player ship in the DestroyObject() function and just add a return after case tPlayer: and uncomment the code that adds Asteroids when you press A then [&#8230;]</p>
The post <a href="https://learncgames.com/raspberry-pi-4-perfect-for-arcade-quality-games-and-development/">Raspberry Pi 4 – Perfect for arcade quality games and development</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignleft size-medium wp-image-461" src="https://learncgames.com/wp-content/uploads/2020/04/lots-of-asteroids-300x236.png" alt="lot s of asteroids" width="300" height="236" srcset="https://learncgames.com/wp-content/uploads/2020/04/lots-of-asteroids-300x236.png 300w, https://learncgames.com/wp-content/uploads/2020/04/lots-of-asteroids-768x604.png 768w, https://learncgames.com/wp-content/uploads/2020/04/lots-of-asteroids.png 1023w" sizes="(max-width: 300px) 100vw, 300px" />I got my Pi 4 a week ago and have been doing experiments on it with my Asteroids game. If I disable the line of code that kills the player ship in the <em>DestroyObject()</em> function and just add a return after <em>case tPlayer:</em> and uncomment the code that adds Asteroids when you press A then I can have lots of asteroids on screen. Also set the MAXASTEROIDS #define to 128.</p>
<p>Then you get the likes of this screenshot which is a 1024 x 768 size window. It&#8217;s still running at 40 fps, there are 116 asteroids on screen, around 60-70 explosions and the Pi&#8217;s temperature is still a balmy 44.79 C. I&#8217;ve never got the Pi&#8217;s temperature (and it does have an internal 3.3V fan) to rise above 51 C.</p>
<p>But what&#8217;s also impressive is that with Visual Studio Code and Clang on the PI, I can compile the whole 2,200 lines of C on the PI in about a second. This makes the Pi very usable for developing games. And I say this as someone who is used to powerful Windows PCs for compiling code.</p>
<p>This is it running in debug mode; that&#8217;s all the numbers and wire frame bounding boxes around every moving object.</p>
<p>Further experimenting and removing the limitations (I used a While loop to limit it to 60 fps back before I had enabled the hardware video flyback). With that while removed and the hardware video flyback disabled, I was getting over 100 fps with 100 asteroids on screen at once.  I pushed it up to 6,000 asteroids and the frame rate dropped to 10 fps. Given the amount of stuff that was colliding and blowing up, that&#8217;s still very good.</p>The post <a href="https://learncgames.com/raspberry-pi-4-perfect-for-arcade-quality-games-and-development/">Raspberry Pi 4 – Perfect for arcade quality games and development</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">460</post-id>	</item>
		<item>
		<title>Building Asteroids on a Raspberry-Pi</title>
		<link>https://learncgames.com/building-asteroids-on-a-raspberry-pi/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-asteroids-on-a-raspberry-pi</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 16 Apr 2020 23:00:08 +0000</pubDate>
				<category><![CDATA[Clang]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[Visual Studio Code]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=393</guid>

					<description><![CDATA[<p>Silly me completely forgot that Raspberry Pis have a different CPU architecture compared to my PC. You just get used to something working on Linux and it was only after copying and it didn&#8217;t run that I realised my mistake. So I now have to recompile Asteroids (from Chapter-48.zip). I&#8217;ve had a Raspberry-Pi 3 B+ [&#8230;]</p>
The post <a href="https://learncgames.com/building-asteroids-on-a-raspberry-pi/">Building Asteroids on a Raspberry-Pi</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;},{&quot;id&quot;:776,&quot;href&quot;:&quot;https:\/\/www.raspberrypi.org&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206074141\/https:\/\/www.raspberrypi.org\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 18:26:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 19:38:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 14:11:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-20 16:20:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 16:31:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-04 20:45:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 10:13:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 12:23:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 11:03:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 19:15:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 10:42:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-12 13:35:43&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-12 13:35:43&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:777,&quot;href&quot;:&quot;https:\/\/sourceforge.net\/projects\/win32diskimager&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260201042202\/https:\/\/sourceforge.net\/projects\/win32diskimager\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 18:26:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 19:38:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 14:11:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 16:20:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 16:30:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-04 20:45:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 10:13:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 12:23:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 11:03:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-02 19:15:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-09 10:42:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-12 13:35:42&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-12 13:35:42&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:733,&quot;href&quot;:&quot;https:\/\/winscp.net\/eng\/index.php&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206023418\/https:\/\/winscp.net\/eng\/index.php&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 18:05:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-11 00:52:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 14:11:57&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 16:20:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 11:22:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 16:30:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-04 16:16:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 06:32:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 10:13:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 10:22:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 12:23:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 11:03:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-02 19:15:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-08 00:14:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-12 13:35:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-20 16:12:23&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 16:12:23&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:673,&quot;href&quot;:&quot;http:\/\/code.headmelted.com&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20201201232800\/http:\/\/code.headmelted.com\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 17:24:11&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-12 19:38:44&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-17 05:26:17&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-20 16:20:56&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-27 16:30:51&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-04 20:45:44&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-08 11:39:35&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-11 18:06:24&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-15 04:58:03&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-22 17:26:41&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-28 14:01:53&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-02 19:15:45&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-09 10:42:45&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 13:35:41&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-12 13:35:41&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-394" src="https://learncgames.com/wp-content/uploads/2020/04/raspi-asteroids-300x262.png" alt="My asteroids running on a Raspberry-Pi 3B+" width="300" height="262" srcset="https://learncgames.com/wp-content/uploads/2020/04/raspi-asteroids-300x262.png 300w, https://learncgames.com/wp-content/uploads/2020/04/raspi-asteroids-768x671.png 768w, https://learncgames.com/wp-content/uploads/2020/04/raspi-asteroids.png 1024w" sizes="auto, (max-width: 300px) 100vw, 300px" />Silly me completely forgot that Raspberry Pis have a different CPU architecture compared to my PC. You just get used to something working on Linux and it was only after copying and it didn&#8217;t run that I realised my mistake. So I now have to recompile Asteroids (from <a href="https://github.com/David-H-Bolton/LearnCOnLinux" target="_blank" rel="noopener noreferrer">Chapter-48.zip</a>).</p>
<p>I&#8217;ve had a Raspberry-Pi 3 B+ for a year and wanted to run the Linux asteroids on it, now that I have it working on Ubuntu.</p>
<p>To do that I had to setup  Pi, running Raspbian downloaded from the <a href="https://www.raspberrypi.org/" target="_blank" rel="noopener noreferrer">Raspberry Pi website</a> onto my Windows PC and then I used <a href="https://sourceforge.net/projects/win32diskimager/" target="_blank" rel="noopener noreferrer">Win32 DiskImager</a> (free Windows software) to burn the Raspbian OS onto a SD Card. Raspberry-Pis boot from SD Cards and the better and faster the SD card, the quicker the OS runs. Get a class 10 with A1 SD Card if you can.</p>
<p>After the Pi booted and Raspbian was installed and configured I had to enable SSH on the Pi; it&#8217;s disabled by default.</p>
<p>So now my PC was talking to the Pi using the excellent free <a href="https://winscp.net/eng/index.php" target="_blank" rel="noopener noreferrer">WinSCP</a>.  I copied all the files over, including the masks, sounds and images folders and all the source code and my exe built on Ubuntu which was the wrong file type. (<em>Trying to run Intel code on an ARM- good luck with that!)</em></p>
<p>Now it turns out that the Raspbian version I installed (I&#8217;d gone for the Raspbian Buster with desktop and recommended software-2.5 GB download) included the non-dev version of SDL2. But as I needed to recompile the whole program, I had to install Visual Studio Code, Clang and the dev versions of SDL2, image and mixer.</p>
<h3>Visual Studio Code on Arm?</h3>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-397" src="https://learncgames.com/wp-content/uploads/2020/04/VSCode-Raspberry-pi-300x245.png" alt="Haedmelted VS Code running on Raspberry Pi 3b+" width="300" height="245" srcset="https://learncgames.com/wp-content/uploads/2020/04/VSCode-Raspberry-pi-300x245.png 300w, https://learncgames.com/wp-content/uploads/2020/04/VSCode-Raspberry-pi-1024x835.png 1024w, https://learncgames.com/wp-content/uploads/2020/04/VSCode-Raspberry-pi-768x626.png 768w, https://learncgames.com/wp-content/uploads/2020/04/VSCode-Raspberry-pi.png 1029w" sizes="auto, (max-width: 300px) 100vw, 300px" />Microsoft don&#8217;t do an official version for Raspberry-Pi or other ARM boards. However I discovered that a developer called Jay Rodgers has taken their source code (VS Code is open source) and  you can get a version <a href="http://code.headmelted.com/" target="_blank" rel="noopener noreferrer">from his site</a>. It&#8217;s very usable on the Pi. Almost but not quite identical.</p>
<p>After installing the dev versions of libsdl2, image and mixer, I was almost able to compile it. I&#8217;d installed Clang but unlike the version on Ubuntu which was Clang-6, the version on Raspbian (based on Debian Buster) is Clang-7.</p>
<p>This means you have to edit the tasks.json file in the hidden .vscode folder. On line 25 where it says <strong>&#8220;command&#8221;</strong>: change the path to <strong>&#8220;/usr/bin/clang-7&#8221;.</strong></p>
<p>That built ok, but when I ran it, it stopped with an error in the <strong>errorlog.txt</strong> file. For some reason, it failed loading the file <strong>&#8220;masks/am2.msk&#8221;</strong>.  Now I&#8217;d had no errors copying files from Windows to the Pi. This had been a very intermittent problem when copying several files in one go from Windows 10 to Ubuntu running under Hyper-V. Occasionally it would come up with some weird error but usually copied OK on the second go.</p>
<p>Despite several attempts, I could not get it to load that mask so as a temp fix I commented the line out. This means that one of the four asteroids sizes can never collide with anything. But it now ran.</p>
<p>However, I&#8217;m only getting about 25-27 fps with it in the early levels, not the 60 fps that I get on Ubuntu on other hardware. Given that the bulk of the work is blitting graphics, I suspect the GPU is just a bit under powered. Apparently on the Raspberry Pi 4, the GPU is newer and twice as fast as on the 3B+ so I&#8217;ll have to try it on a 4 when I get one. But the game works and is just about playable.</p>
<p>Now I&#8217;ll have to try and figure out why it won&#8217;t load that one mask. This has the makings of an interesting bug&#8230;</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/building-asteroids-on-a-raspberry-pi/">Building Asteroids on a Raspberry-Pi</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">393</post-id>	</item>
		<item>
		<title>Install Clang and Visual Studio Code on Ubuntu</title>
		<link>https://learncgames.com/install-clang-and-visual-studio-code-on-ubuntu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-clang-and-visual-studio-code-on-ubuntu</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 14 Apr 2020 23:00:27 +0000</pubDate>
				<category><![CDATA[Clang]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio Code]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=379</guid>

					<description><![CDATA[<p>Clang is very easy to install. Open a terminal and issue this command: sudo apt install clang It takes a little bit more for Visual Studio Code (aka VS Code). Start on the download page of VS Code. Just google for download Visual Studio Code or click here. Click the Deb rectangle and pick the Open [&#8230;]</p>
The post <a href="https://learncgames.com/install-clang-and-visual-studio-code-on-ubuntu/">Install Clang and Visual Studio Code on Ubuntu</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;:778,&quot;href&quot;:&quot;https:\/\/code.visualstudio.com\/download&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205023359\/https:\/\/code.visualstudio.com\/download&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 18:35:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 02:46:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 07:04:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 19:22:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 04:58:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 16:09:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 11:03:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 12:33:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-13 11:20:01&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-13 11:20:01&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-382" src="https://learncgames.com/wp-content/uploads/2020/04/vscode.png" alt="Visual Studio Code" width="966" height="726" srcset="https://learncgames.com/wp-content/uploads/2020/04/vscode.png 966w, https://learncgames.com/wp-content/uploads/2020/04/vscode-300x225.png 300w, https://learncgames.com/wp-content/uploads/2020/04/vscode-768x577.png 768w" sizes="auto, (max-width: 966px) 100vw, 966px" />Clang is very easy to install. Open a terminal and issue this command:</p>
<pre><code class="language-bash" data-line="">sudo apt install clang</code></pre>
<p>It takes a little bit more for Visual Studio Code (aka VS Code). Start on the download page of VS Code. Just google for download Visual Studio Code or <a href="https://code.visualstudio.com/download" target="_blank" rel="noopener noreferrer">click here</a>. Click the Deb rectangle and pick the Open with Software install (default) and that will install it.</p>
<p>After that is installed, run VS Code (<em>open a terminal and type code</em>) and click the extensions icon (5th down on the left) and type in C++ in the search box. The first result is by Microsoft so select it and click install.</p>
<p>Now I created a Projects folder under my home, so click on open Folder in the File menu and select Projects. You can create individual folders for applications under that. If you look closely you can see Asteroids, AsteroidsDND and Examples with Asteroids being open and containing two .c files.</p>
<p>To compile, make sure the open tab is the file you wish to compile then click Terminal on the top menu and Run Build Task&#8230;  You&#8217;ll see the compiled programs on the left under the Asteroids folder (decnot and ex1).</p>
<p>There&#8217;s a bit more for configuring Builds and Debugging but I&#8217;ll cover that another time.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/install-clang-and-visual-studio-code-on-ubuntu/">Install Clang and Visual Studio Code on Ubuntu</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">379</post-id>	</item>
		<item>
		<title>Comparing MSVC vs Clang</title>
		<link>https://learncgames.com/comparing-msvc-vs-clang/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=comparing-msvc-vs-clang</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 31 Mar 2020 23:00:12 +0000</pubDate>
				<category><![CDATA[Clang]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[clang]]></category>
		<category><![CDATA[msvc]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=275</guid>

					<description><![CDATA[<p>I originally created Asteroids for Windows using Visual Studio 2017 Community Edition. Since then I&#8217;ve started the Clang version on Ubuntu and there haven&#8217;t been too many differences but there are just a few so in this post I&#8217;ll list what I&#8217;ve found so far. Include Paths On Windows, I was able to get away [&#8230;]</p>
The post <a href="https://learncgames.com/comparing-msvc-vs-clang/">Comparing MSVC vs Clang</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="size-medium wp-image-277 alignleft" src="https://learncgames.com/wp-content/uploads/2020/03/codelisting-300x172.png" alt="Listing of some C code" width="300" height="172" srcset="https://learncgames.com/wp-content/uploads/2020/03/codelisting-300x172.png 300w, https://learncgames.com/wp-content/uploads/2020/03/codelisting.png 638w" sizes="auto, (max-width: 300px) 100vw, 300px" />I originally created Asteroids for Windows using Visual Studio 2017 Community Edition. Since then I&#8217;ve started the Clang version on Ubuntu and there haven&#8217;t been too many differences but there are just a few so in this post I&#8217;ll list what I&#8217;ve found so far.</p>
<h3>Include Paths</h3>
<p>On Windows, I was able to get away with #include &lt;SDL.h&gt; but on Linux, I&#8217;ve had to include the path so it&#8217;s #include &lt;SDL2/SDL.h&gt;. This was probably because I included the full path in the MSVC configuration.</p>
<h3>Link Failures</h3>
<p>The asteroids.c code in chapter 29 uses sin and cos for the first time and the linker was unhappy with that. So in tasks.json, I&#8217;ve explicitly had to add it into args, along with SDL2 and SDL2_image,</p>
<pre><code class="language-c" data-line="">            &quot;args&quot;: [
                &quot;-g&quot;,
                &quot;${file}&quot;,&quot;${workspaceFolder}/Asteroids/hr_time.c&quot;,
                &quot;-o&quot;,
                &quot;${fileDirname}/asteroids&quot;,                
                &quot;-lSDL2&quot;,
                &quot;-lSDL2_image&quot;,
                &quot;-lm&quot;
            ],</code></pre>
<p>That &#8220;-lm&#8221; does that for maths.</p>
<h3>Safe functions</h3>
<p>Microsoft has its own set of safe functions many with an _s and extra length parameter.</p>
<p>On Linux, there don&#8217;t seem to be so many.</p>
<p>So sprintf_s on Windows becomes snprintf.</p>
<p>fopen_s just becomes standard fopen</p>
<h3>linux/time.h</h3>
<p>As well as time.h in the includes, I needed to add linux/time.h as well.</p>The post <a href="https://learncgames.com/comparing-msvc-vs-clang/">Comparing MSVC vs Clang</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">275</post-id>	</item>
		<item>
		<title>I&#8217;m considering switching to C11</title>
		<link>https://learncgames.com/im-considering-switching-to-c11/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=im-considering-switching-to-c11</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 16 Mar 2020 00:00:45 +0000</pubDate>
				<category><![CDATA[Clang]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[C11]]></category>
		<category><![CDATA[C99]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=134</guid>

					<description><![CDATA[<p>All C code I write in the books is currently to the C99 standard. All the compilers involved (Visual C++ on Windows and Clang on Ubuntu) support C99 but C11 support seems restricted to GCC and Clang. Microsoft has traditionally supported C++ but their C support seems a bit grudging; realistically they don&#8217;t prioritise it [&#8230;]</p>
The post <a href="https://learncgames.com/im-considering-switching-to-c11/">I’m considering switching to C11</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;:472,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/geralt-9301\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=942487&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260128125116\/https:\/\/pixabay.com\/users\/geralt-9301\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 15:15:42&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 02:14:17&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-22 09:31:10&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-04 22:26:50&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-10 14:16:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-15 04:58:11&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-25 06:58:02&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-30 05:47:12&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 04:25:33&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-10 01:48:01&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 13:39:47&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 23:08:37&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 23:08:37&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:473,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=942487&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 15:15:44&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-12 02:14:17&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-22 09:31:09&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-04 22:26:50&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-10 14:16:21&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-15 04:58:05&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-25 06:58:02&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-30 05:47:13&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-05 04:25:31&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-10 01:48:00&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-17 13:39:38&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-21 23:08:41&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 23:08:41&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:817,&quot;href&quot;:&quot;https:\/\/en.wikichip.org\/wiki\/c\/c11&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20210506225725\/https:\/\/en.wikichip.org\/wiki\/c\/c11&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 19:36:02&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-02-11 21:41:38&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-02-23 00:07:14&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-03-04 22:26:50&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-03-10 14:16:22&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-03-15 04:58:08&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-03-25 06:58:02&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-03-30 05:47:12&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-04-07 11:32:05&quot;,&quot;http_code&quot;:520},{&quot;date&quot;:&quot;2026-04-11 20:05:37&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-21 23:08:45&quot;,&quot;http_code&quot;:503}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 23:08:45&quot;,&quot;http_code&quot;:503},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:818,&quot;href&quot;:&quot;https:\/\/smartbear.com\/blog\/test-and-monitor\/c11-a-new-c-standard-aiming-at-safer-programming&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;https:\/\/smartbear.com\/blog\/test-and-monitor\/c11-a-new-c-standard-aiming-at-safer-programming\/&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_138" aria-describedby="caption-attachment-138" style="width: 300px" class="wp-caption alignleft"><img loading="lazy" decoding="async" class="size-medium wp-image-138" src="https://learncgames.com/wp-content/uploads/2020/03/programming-942487_1280-300x212.jpg" alt="Programming image" width="300" height="212" srcset="https://learncgames.com/wp-content/uploads/2020/03/programming-942487_1280-300x212.jpg 300w, https://learncgames.com/wp-content/uploads/2020/03/programming-942487_1280-1024x723.jpg 1024w, https://learncgames.com/wp-content/uploads/2020/03/programming-942487_1280-768x542.jpg 768w, https://learncgames.com/wp-content/uploads/2020/03/programming-942487_1280.jpg 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-138" class="wp-caption-text">Image by <a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=942487">Gerd Altmann</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=942487">Pixabay</a></figcaption></figure>
<p>All C code I write in the books is currently to the C99 standard. All the compilers involved (Visual C++ on Windows and Clang on Ubuntu) support C99 but C11 support seems restricted to GCC and Clang.</p>
<p>Microsoft has traditionally supported C++ but their C support seems a bit grudging; realistically they don&#8217;t prioritise it which I can understand.</p>
<p>Given though that I&#8217;m not going to republish my first e-book for a while (I&#8217;d like to add a WebAssembly chapter or two first), I&#8217;m going to investigate whether it&#8217;s worth switching to C11 for the 2nd book. From what I&#8217;ve read all it needs is a flag to tll it to compile to C11 standards. This is for Clang.</p>
<p>-std=c11</p>
<p>But the other question is <strong>what will I gain by doing this</strong> and I can&#8217;t actually see there&#8217;s that much benefit.. I don&#8217;t need Unicode, I don&#8217;t think alignment will really make much difference. You can read about the C11 changes on <a href="https://en.wikichip.org/wiki/c/c11" target="_blank" rel="noopener noreferrer">WikiChip.</a></p>
<p>So I&#8217;ve made the decision. I&#8217;ll stick with C99 for now. But for an alternative view, I recommend <a href="https://smartbear.com/blog/test-and-monitor/c11-a-new-c-standard-aiming-at-safer-programming/" target="_blank" rel="noopener noreferrer">Danny Kalev&#8217;s 2012 article on C11</a>.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/im-considering-switching-to-c11/">I’m considering switching to C11</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">134</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>
	</channel>
</rss>
