<?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/category/c-2/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>Mon, 26 May 2025 15:50:21 +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>Setting up SDL3 on Linux</title>
		<link>https://learncgames.com/setting-up-sdl3-on-linux/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-sdl3-on-linux</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 26 May 2025 15:02:41 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[SDL3 on Linux]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3420</guid>

					<description><![CDATA[<p>I knew it wasn&#8217;t going to be easy, but it turned out to be quite a bit more difficult than I thought. The problem is, unlike SDL2, there are no dev versions of SDL3 etc. yet, so you have to build it from scratch. I&#8217;ll be honest, I&#8217;m not sure I could have done it [&#8230;]</p>
The post <a href="https://learncgames.com/setting-up-sdl3-on-linux/">Setting up SDL3 on Linux</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;:17,&quot;href&quot;:&quot;https:\/\/github.com\/Ravbug\/sdl3-sample&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260112022859\/https:\/\/github.com\/Ravbug\/sdl3-sample&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 18:04:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:36:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 23:18:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 00:34:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 04:11:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 10:07:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 10:09:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 12:37:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 17:22:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 18:51:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 20:26:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 21:57:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 06:22:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 08:22:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-25 10:53:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-28 10:54:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 11:05:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 11:05:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 11:57:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 12:21:08&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 12:50:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 13:16:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 19:14:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 20:49:12&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 20:49:12&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:18,&quot;href&quot;:&quot;https:\/\/github.com\/Ravbug\/sdl3-sample\/wiki\/Setting-up-your-computer&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250505154154\/https:\/\/github.com\/Ravbug\/sdl3-sample\/wiki\/Setting-up-your-computer&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 18:04:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:36:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 23:18:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 00:35:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 04:11:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 10:07:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 10:09:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 12:37:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 17:22:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 18:51:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 20:26:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 21:57:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 06:22:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 08:22:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-25 10:53:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-28 10:54:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 11:05:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 15:25:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 15:37:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 19:09:51&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 20:24:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 20:58:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-19 01:38:24&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 01:38:24&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-3421" src="https://learncgames.com/wp-content/uploads/2025/05/sdl3-1.png" alt="SDL3 program running on Raspberry Pi." width="550" height="514" srcset="https://learncgames.com/wp-content/uploads/2025/05/sdl3-1.png 550w, https://learncgames.com/wp-content/uploads/2025/05/sdl3-1-300x280.png 300w" sizes="(max-width: 550px) 100vw, 550px" /></p>
<p>I knew it wasn&#8217;t going to be easy, but it turned out to be quite a bit more difficult than I thought.</p>
<p>The problem is, unlike SDL2, there are no dev versions of SDL3 etc. yet, so you have to build it from scratch.</p>
<p>I&#8217;ll be honest, I&#8217;m not sure I could have done it without this <a title="Link to Ravbug's Setting up SDL3 sample on GitHub" href="https://github.com/Ravbug/sdl3-sample" target="_blank" rel="noopener">GitHub repository</a>. User <em>Ravbug</em> who is very busy person (<em>752 contributions on GitHub in the last year- I tip my hat to him or her!</em>) who provided that repository.</p>
<p>It sets up SDL3, SDL_image, sdl_mixer and SDL_ttf.</p>
<p>Follow his link to the <a title="Ravbug's instructions" href="https://github.com/Ravbug/sdl3-sample/wiki/Setting-up-your-computer" target="_blank" rel="noopener">Wiki page</a> Scroll down to the bottom for the Linux instructions. I can confirm that it works on Raspberry Pi as well.  You&#8217;ll need to install cmake first with</p>
<pre>sudo apt install cmake</pre>
<p>Then run his cmake to build everything and go for a coffee.<br />
Now go into the build folder under sdl3-sample and do</p>
<pre>make</pre>
<p>That only takes a second or so.</p>
<p>After you&#8217;ve done that you&#8217;ll end up with a load of files including an executable sdl-min that you can run. That&#8217;s what generated the Tiger&#8217;s head &#8211; it plays The Sting film&#8217;s theme (The Entertainer) music as well demonstrating that it&#8217;s using SDL_mixer as well as SDL3 and SDL_ttf (<em>I&#8217;m guessing</em>) and of course SDL_image.</p>
<h3>But that is just the start</h3>
<p>To use SDL3 etc in your C program, you need a bit more configuration than with SDL2. I&#8217;m in uncharted waters here but used an AI- Claude 4 to help me get through and it did.</p>
<p>The problem is you have to tell VS Code where the header files are located, the .so files and also the executable needs to know at runtime.</p>
<p>I set up Ravbug&#8217;s sdl3_sample in my home folder so all paths start <strong>/home/david/sdl3-sample. </strong></p>
<p>This is my tasks.json</p>
<p>&nbsp;</p>
<pre><code class="language-json" data-line="">{
    &quot;version&quot;: &quot;2.0.0&quot;,
    &quot;tasks&quot;: [
        {
            &quot;type&quot;: &quot;shell&quot;,
            &quot;label&quot;: &quot;clang-14.0 build active file&quot;,
            &quot;command&quot;: &quot;/usr/bin/clang-14&quot;,
            &quot;args&quot;: [
                &quot;-I/home/david/sdl3-sample/SDL/include&quot;,
                &quot;-I/home/david/sdl3-sample/SDL_image/include&quot;, 
                &quot;-I/home/david/sdl3-sample/SDL_mixer/include&quot;,
                &quot;-I/home/david/sdl3-sample/SDL_ttf/include&quot;,
                &quot;-g&quot;,
                &quot;${file}&quot;,&quot;${workspaceFolder}/hr_time.c&quot;,
                &quot;-L/home/david/sdl3-sample/build&quot;,	
                &quot;-Wl,-rpath,/home/david/sdl3-sample/build&quot;,				
                &quot;-o&quot;,
                &quot;${fileDirname}/${fileBasenameNoExtension}&quot;,
                &quot;-lSDL3&quot;,
                &quot;-lSDL3_image&quot;, 
                &quot;-lSDL3_ttf&quot;   

            ],
            &quot;options&quot;: {
                &quot;cwd&quot;: &quot;/usr/bin&quot;
            },
            &quot;group&quot;: {
                &quot;kind&quot;: &quot;build&quot;,
                &quot;isDefault&quot;: true
            }
        }
    ]
}</code></pre>
<p>The lines that are SDL3 specific include the -I&#8217;s to provide the include path. -L the path to the .so files and the -rpath line is the path to the runtime files which gets linked into the executable.</p>
<p>If you add these three lines into c_cpp_properties.json then you&#8217;ll also avoid the dreaded red squiggles.</p>
<pre><code class="language-json" data-line="">            &quot;includePath&quot;: [
                &quot;${workspaceFolder}/**&quot;,
                &quot;/home/david/sdl3-sample/SDL/include&quot;,
                &quot;/home/david/sdl3-sample/SDL_image/include&quot;,
                &quot;/home/david/sdl3-sample/SDL_ttf/include&quot;
            ],</code></pre>
<pre><code class="language-json" data-line="">
</code></pre>
<p>And your C&#8217;s #includes need the files prefixed like this :</p>
<pre>#include &lt;SDL3/SDL.h&gt;
#include &lt;SDL3_image/SDL_image.h&gt;
#include &lt;SDL3_ttf/SDL_ttf.h&gt;</pre>
<p>And here it is running on my Pi.</p>
<p><img decoding="async" class="alignleft wp-image-3422 size-large" src="https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-1024x780.png" alt="Missile Command running on a Raspberry Pi 5 with SDL3" width="1024" height="780" srcset="https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-1024x780.png 1024w, https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-300x229.png 300w, https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-768x585.png 768w, https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi.png 1108w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>The post <a href="https://learncgames.com/setting-up-sdl3-on-linux/">Setting up SDL3 on Linux</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">3420</post-id>	</item>
		<item>
		<title>Converting from SDL2 to SDL3 on Windows</title>
		<link>https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=converting-from-sdl2-to-sdl3-on-windows</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 24 May 2025 14:21:56 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[SDL2]]></category>
		<category><![CDATA[SDL3]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3414</guid>

					<description><![CDATA[<p>These notes were made when converting an existing C game that used SDL2 to SDL3 on Windows. The game was originally developed for Linux Format and I had got it running on Windows with SDL2. Windows include paths have been made consistent with Linux. The include files path for SDL3 need to be SDL3\&#8230; when [&#8230;]</p>
The post <a href="https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/">Converting from SDL2 to SDL3 on Windows</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-3418" src="https://learncgames.com/wp-content/uploads/2025/05/SDL3-300x232.png" alt="Missile Command running with SDL3" width="600" height="463" srcset="https://learncgames.com/wp-content/uploads/2025/05/SDL3-300x232.png 300w, https://learncgames.com/wp-content/uploads/2025/05/SDL3-1024x790.png 1024w, https://learncgames.com/wp-content/uploads/2025/05/SDL3-768x593.png 768w, https://learncgames.com/wp-content/uploads/2025/05/SDL3.png 1026w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>These notes were made when converting an existing C game that used SDL2 to SDL3 on Windows. The game was originally developed for Linux Format and I had got it running on Windows with SDL2.</p>
<p>Windows include paths have been made consistent with Linux. The include files path for SDL3 need to be SDL3\&#8230; when setting them up. For SDL2, I had them in a folder c:\SDL2\include but noted that in SDL2.h include files were like this:</p>
<pre>#include "SDL_main.h"
#include "SDL_stdinc.h"</pre>
<p>While in SDL3&#8217;s SDL.h they are</p>
<pre>#include &lt;SDL3/SDL_stdinc.h&gt;
#include &lt;SDL3/SDL_assert.h&gt;</pre>
<p>So I put them c:\SDL3\SDL3</p>
<p>When you include them in your software they are like this:</p>
<pre>#include &lt;SDL3/SDL.h&gt;
#include &lt;SDL3/SDL_image.h&gt;</pre>
<p>Which is how they are in Linux.</p>
<p>The rest of these notes are taken from the differences between the SDL2 and SDL3 versions of the game. They are not complete but intended to give you an idea of some of the changes you may need to do.</p>
<h3>SDL_TTF</h3>
<p>TTF_RenderUTF8_Blended( is now TTF_RenderText_Blended with an extra text length parameter.</p>
<h3>SDL_Rects are mostly replaced by SDL_FRect</h3>
<p>This is a big change. Everywhere I was passing in an SDL_Rect became an SDL_Frect which is four floats rather than four ints.</p>
<p>SDL_RenderCopy is now SDL_RenderTexture and the last two params are now SDL_FRects.</p>
<p>To fix this I used a load of (float) casts.</p>
<p><strong>SDL_RenderDrawLine</strong> becomes <strong>SDL_RenderLine</strong> and has an SDL_FRect parameter instaed of SDL_Rect.</p>
<p>Same for <strong>SDL_RenderDrawPoint</strong> which becomes <strong>SDL_RenderPoint</strong>.</p>
<p><strong>SDL_GetMouseState</strong> keeps the same name but returns float * for both parameters now.</p>
<h3>Setup changes slightly</h3>
<p>There&#8217;s no <strong>SDL_SetMainReady()</strong> and SDL2main.lib is gone.</p>
<p>Also gone is <strong>SDL_INIT_EVERYTHING</strong> in <strong>SDL_Init()</strong>&#8211; you have to or the specific subunits. E.g. SDL_INIT_VIDEO | SDL_INIT_EVENTS</p>
<p>Also there&#8217;s no <strong>SDL_RENDERER_PRESENTVSYNC </strong>for SDL_CreateRenderer. Vsync is disabled by default as I found when my game ran about 30x faster and finished in a few seconds! Instead you need to call SDL_SetRenderVSync(renderer, 1) where 1 is syncing with each retrace, or 2 with every 2nd retrace.</p>
<p>Several of the events have been renamed, so SDL_KEYDOWN becomes SDL_EVENT_KEY_DOWN, SDL_MOUSEBUTTONDOWN becomes  SDL_EVENT_MOUSE_BUTTON_DOWN and similar for other events.  Also event.key.keysym.sym becomes event.key.key.</p>
<p>Finally SDL_FreeSurface( becomes SDL_DestroySurface.</p>
<p>I&#8217;m sure there are more but changing these was sufficent to get my game compiling and running correctly with SDL3.</p>The post <a href="https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/">Converting from SDL2 to SDL3 on Windows</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">3414</post-id>	</item>
		<item>
		<title>New tutorial posted &#8211; how to build controllermap in Linux</title>
		<link>https://learncgames.com/new-tutorial-posted-how-to-build-controllermap-in-linux/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-tutorial-posted-how-to-build-controllermap-in-linux</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 22 Mar 2025 12:11:07 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[controllermap]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[SDL2]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3354</guid>

					<description><![CDATA[<p>Remember controllermap? The utility that creates a configuration string for a game pad etc. I found that it is no longer installed by default when you install libsdl2-dev on Linux.  I found the hard way, trying to use it on my new Raspbverry Piu 5. But the source code is available for it in the [&#8230;]</p>
The post <a href="https://learncgames.com/new-tutorial-posted-how-to-build-controllermap-in-linux/">New tutorial posted – how to build controllermap in Linux</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-full wp-image-3352" src="https://learncgames.com/wp-content/uploads/2025/03/controllermap.png" alt="Controllermap utility" width="514" height="344" srcset="https://learncgames.com/wp-content/uploads/2025/03/controllermap.png 514w, https://learncgames.com/wp-content/uploads/2025/03/controllermap-300x201.png 300w" sizes="auto, (max-width: 514px) 100vw, 514px" /></p>
<p>Remember controllermap? The utility that creates a configuration string for a game pad etc. I found that it is no longer installed by default when you install libsdl2-dev on Linux.  I found the hard way, trying to use it on my new Raspbverry Piu 5.</p>
<p>But the source code is available for it in the libsdl 2 releases.</p>
<p>So I wrote a quick tutorial that explains how to get the source code and build it using clang on VS Code on a Pi or any Linux box.  It&#8217;s <a title="Link to tutorial how to build controllermap on Linux" href="https://learncgames.com/tutorials/how-to-build-controllermap-on-linux-for-sdl2/" target="_blank" rel="noopener">linked here</a> or you can find it on the tutorials menu.</p>The post <a href="https://learncgames.com/new-tutorial-posted-how-to-build-controllermap-in-linux/">New tutorial posted – how to build controllermap in Linux</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">3354</post-id>	</item>
		<item>
		<title>Compiling C with Visual C++ 2022</title>
		<link>https://learncgames.com/compiling-c-with-visual-c-2022/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=compiling-c-with-visual-c-2022</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 28 Mar 2023 23:00:22 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[settings]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3237</guid>

					<description><![CDATA[<p>It&#8217;s been a few years since I compiled the code for the first eBook and I needed to create an SDL application on Windows. I copied a project, as it was the fastest way to setup the include and lib paths, and the lib files needed to compile. Compared to clang/gcc on Linux, setting up [&#8230;]</p>
The post <a href="https://learncgames.com/compiling-c-with-visual-c-2022/">Compiling C with Visual C++ 2022</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-3239" src="https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-300x200.jpg" alt="monitor displaying programming language" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-1024x683.jpg 1024w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-768x512.jpg 768w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-1536x1024.jpg 1536w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q.jpg 1600w" sizes="auto, (max-width: 300px) 100vw, 300px" />It&#8217;s been a few years since I compiled the code for the first eBook and I needed to create an SDL application on Windows. I copied a project, as it was the fastest way to setup the <em>include</em> and <em>lib</em> paths, and the lib files needed to compile.</p>
<p>Compared to clang/gcc on Linux, setting up visual studio projects on Windows can be a bit of a pita. You&#8217;ve got to be careful not to mix up the x64 and x86 files, add everything twice (once for Win 32 and once for x64).</p>
<p>So I copied .sln and .vcxproj files, started compiling and kept getting this error:</p>
<p><em>Error LNK2019 unresolved external symbol main referenced in function &#8220;int __cdecl invoke_main(void)&#8221; (?invoke_main@@YAHXZ) maze D:\development\LinuxFormat\maze\MSVCRTD.lib(exe_main.obj) </em></p>
<p>I messed around with settings, still no joy. did a bit of searching around and found that some people fixed it by setting the Link System Subsystem but that didn&#8217;t fix it. Also one person had forgotten to add SDL2_main.lib to the list of lib files to be linked in.</p>
<p>Then I noticed the project was defaulting to 64-bit. I checked my includes and it was only setup for 32-bit. D&#8217;oh. So copying the settings from 32-bit to 64-bit fixed it.</p>The post <a href="https://learncgames.com/compiling-c-with-visual-c-2022/">Compiling C with Visual C++ 2022</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">3237</post-id>	</item>
		<item>
		<title>Yet another curious bug</title>
		<link>https://learncgames.com/yet-another-curious-bug/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yet-another-curious-bug</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 26 Mar 2023 23:00:37 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[game]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3225</guid>

					<description><![CDATA[<p>I&#8217;m aware that C is notorious for unexpected behaviour (UB). Let me describe this bug: My second game in C + SDL for my newest eBook is Match Three and compiled with Clang-11 on my Raspberry Pi 4B. I&#8217;m getting a weird bug that doesn&#8217;t occur when I compile it on Windows under MSVC; the [&#8230;]</p>
The post <a href="https://learncgames.com/yet-another-curious-bug/">Yet another curious bug</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-3227" src="https://learncgames.com/wp-content/uploads/2023/03/matchthree-bug-300x233.png" alt="MatchThree latest version with a bug" width="300" height="233" srcset="https://learncgames.com/wp-content/uploads/2023/03/matchthree-bug-300x233.png 300w, https://learncgames.com/wp-content/uploads/2023/03/matchthree-bug-1024x796.png 1024w, https://learncgames.com/wp-content/uploads/2023/03/matchthree-bug-768x597.png 768w, https://learncgames.com/wp-content/uploads/2023/03/matchthree-bug.png 1036w" sizes="auto, (max-width: 300px) 100vw, 300px" />I&#8217;m aware that C is notorious for unexpected behaviour (UB). Let me describe this bug:</p>
<div data-reddit-rtjson="{&quot;entityMap&quot;:{},&quot;blocks&quot;:[{&quot;key&quot;:&quot;dbbsn&quot;,&quot;text&quot;:&quot;I'm creating a game in C + SDL for an eBook in C and compiled it with Clang-11 on my Raspberry Pi 4B. I'm getting a weird bug that doesn't occur when I compile it on Windows under MSVC; the only differences are the paths to SDL and the sn._s calls but there aren't many of those. Also I compiled it with clang-14 on Ubuntu 22.04 LTS on a Hyper-VM and that behaves properly. &quot;,&quot;type&quot;:&quot;unstyled&quot;,&quot;depth&quot;:0,&quot;inlineStyleRanges&quot;:[],&quot;entityRanges&quot;:[],&quot;data&quot;:{}},{&quot;key&quot;:&quot;34s6i&quot;,&quot;text&quot;:&quot;The weird bug is this. The game is a MatchThree game with 10 x 10 pieces. A 2D array of structs. One field is a field called size. It's 0 normally but if &gt; 0 then it is dec'd and the piece is drawn rotated by 8 degrees. When it reaches 0 the piece is removed. &quot;,&quot;type&quot;:&quot;unstyled&quot;,&quot;depth&quot;:0,&quot;inlineStyleRanges&quot;:[],&quot;entityRanges&quot;:[],&quot;data&quot;:{}}]}">
<div class="" data-block="true" data-editor="35ef0f" data-offset-key="35ef0f_initial-0-0">
<div class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="35ef0f_initial-0-0"><span data-offset-key="35ef0f_initial-0-0">My second game in C + SDL for my newest eBook is Match Three and compiled with Clang-11 on my Raspberry Pi 4B. I&#8217;m getting a weird bug that doesn&#8217;t occur when I compile it on Windows under MSVC; the only differences between the source code on the PI and Windows are the paths to SDL and the sn._s calls but there aren&#8217;t many of those. Also I compiled it with clang-14 on Ubuntu 22.04 LTS on a Hyper-VM and that behaves properly.</span></div>
</div>
<p>&nbsp;</p>
<div data-offset-key="35ef0f_initial-0-0"></div>
<div class="" data-block="true" data-editor="35ef0f" data-offset-key="4u8u6-0-0">
<div class="public-DraftStyleDefault-block public-DraftStyleDefault-ltr" data-offset-key="4u8u6-0-0"><span data-offset-key="4u8u6-0-0">Each piece is held a struct in a 10 x 10 array. One field is  called size. It&#8217;s 0 normally but if it is set to a value, typically  64 then it counts down, one per frame and the piece is drawn rotated by 8 degrees each frame. When it reaches 0 the piece is removed. This is my &#8220;down the plughole&#8221; way of removing pieces. It takes exactly 64/60 seconds to vanish. I use the size field to draw it when size is non-zero so it shrinks as it rotates It&#8217;s a nice effect.</span></div>
</div>
</div>
<p>&nbsp;</p>
<div data-offset-key="4u8u6-0-0"></div>
<div data-offset-key="4u8u6-0-0"></div>
<div data-offset-key="4u8u6-0-0">The bug though is that when it starts up, several pieces start rotating and keep rotating. The size field stays at 63. There&#8217;s no code that explains this behaviour and it only happens on the Raspberry Pi, not on Windows or on Ubuntu. Is it a compiler bug or some weird UB on the PI version. It&#8217;s an interesting bug and I&#8217;ve only wasted a week of evenings on it so far!</div>
<p></p>The post <a href="https://learncgames.com/yet-another-curious-bug/">Yet another curious bug</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">3225</post-id>	</item>
		<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 loading="lazy" 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="auto, (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>Is C a portable language?</title>
		<link>https://learncgames.com/is-c-a-portable-language/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=is-c-a-portable-language</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 02 Feb 2023 00:01:59 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[portability]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3202</guid>

					<description><![CDATA[<p>I occasionally write answers on Quora.com and many recurring questions are about assembly language. Now I used to write games in 6502 and Z80 assembly language when the only alternative was Basic. But assembly language is very tedious to write, painstaking and it&#8217;s slow to write programs in assembly language. Most of your code is [&#8230;]</p>
The post <a href="https://learncgames.com/is-c-a-portable-language/">Is C a portable 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;:33,&quot;href&quot;:&quot;https:\/\/en.wikibooks.org\/wiki\/Portability_and_the_C_Language&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206110747\/https:\/\/en.wikibooks.org\/wiki\/Portability_and_the_C_Language&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-12 06:07:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-18 01:41:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-22 16:09:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-27 16:40:13&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 18:00:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-12 08:07:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-15 12:32:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-21 20:48:49&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-03-26 15:03:44&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-30 22:54:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 01:59:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 05:10:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 01:42:42&quot;,&quot;http_code&quot;:429}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-15 01:42:42&quot;,&quot;http_code&quot;:429},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3203" src="https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq-300x300.jpg" alt="brown and black suitcase with red and yellow plastic toy" width="300" height="300" srcset="https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq-300x300.jpg 300w, https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq-1024x1024.jpg 1024w, https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq-150x150.jpg 150w, https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq-768x768.jpg 768w, https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq-250x250.jpg 250w, https://learncgames.com/wp-content/uploads/2023/02/e2qx9ed2qiq.jpg 1200w" sizes="auto, (max-width: 300px) 100vw, 300px" />I occasionally write answers on Quora.com and many recurring questions are about assembly language. Now I used to write games in 6502 and Z80 assembly language when the only alternative was Basic. But assembly language is very tedious to write, painstaking and it&#8217;s slow to write programs in assembly language. Most of your code is moving values between memory and registers or vice versa.</p>
<p>Anything major you write will not easily port onto a different CPU or Operating System. A Mac uses a different CPU to most Windows PCs and a Raspberry Pi uses a similar CPU design to a Mac (M1 or M2) but there are still differences in calling OS routines on Raspberry Pi OS (based on Debian) and Mac OS.</p>
<p>Higher level languages are generally portable. I&#8217;ve written C# code that runs on Linux and my game which was 2,200 lines of C needed about an hours work to run on Ubuntu Linux and Raspberry Pi.</p>
<p>But if you have a large complex C application, it may have issues when porting it.  A developer Rex Jaeschke wrote a book on portability and published it in 1989. He&#8217;s recently updated it and it&#8217;s available on Wikibooks.  It&#8217;s called <a title="Link to Portability and the C language eBook on Wikibooks" href="https://en.wikibooks.org/wiki/Portability_and_the_C_Language" target="_blank" rel="noopener">Portability and the C language</a> and is several hundred pages long. If you ever want to port C, it is very worthwhile reading. I&#8217;ve added a permanent link to the Link to C utilities page.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/is-c-a-portable-language/">Is C a portable 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">3202</post-id>	</item>
		<item>
		<title>Is Tiobe Index misinformation?</title>
		<link>https://learncgames.com/is-tiobe-index-misinformation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=is-tiobe-index-misinformation</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 15 Jan 2023 00:00:05 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Other stuff]]></category>
		<category><![CDATA[rankings]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3188</guid>

					<description><![CDATA[<p>Every month a new Tiobe Index is published purporting to show the most popular programming languages. Except, if you look at other programming language popularity surveys, lists etc, the Tiobe Index increasingly seems to be at odds with everybody else. Take the programming language C. As you can imagine I have a particular interest in [&#8230;]</p>
The post <a href="https://learncgames.com/is-tiobe-index-misinformation/">Is Tiobe Index misinformation?</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-3195" src="https://learncgames.com/wp-content/uploads/2023/01/2094394-300x200.jpg" alt="news, false, concept" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2023/01/2094394-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2023/01/2094394-1024x682.jpg 1024w, https://learncgames.com/wp-content/uploads/2023/01/2094394-768x512.jpg 768w, https://learncgames.com/wp-content/uploads/2023/01/2094394.jpg 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" />Every month a new Tiobe Index is published purporting to show the most popular programming languages. Except, if you look at other programming language popularity surveys, lists etc, the Tiobe Index increasingly seems to be at odds with everybody else.</p>
<p>Take the programming language C. As you can imagine I have a particular interest in it. I was at first delighted when I saw it at #3 in the Tiobe Index. In fact, in their most recent index it is listed as the 2nd most popular programming language. Well that is just crazy. No matter how much I might want it, there is no way on Earth that it is the 2nd most popular programming language.</p>
<p>It&#8217;s not just me saying it. Let&#8217;s look at who else says it.</p>

<table id="tablepress-1" class="tablepress tablepress-id-1">
<thead>
<tr class="row-1">
	<th class="column-1">Site</th><th class="column-2">C's Ranking</th><th class="column-3">Comments</th>
</tr>
</thead>
<tbody class="row-striping row-hover">
<tr class="row-2">
	<td class="column-1"><a href="https://www.tiobe.com/tiobe-index/">Tiobe Index</a></td><td class="column-2">2</td><td class="column-3">Updated monthly</td>
</tr>
<tr class="row-3">
	<td class="column-1"><a href="https://octoverse.github.com/2022/top-programming-languages">GitHub Octoverse Programming languages</a></td><td class="column-2">9</td><td class="column-3">Annually- this is October 2022</td>
</tr>
<tr class="row-4">
	<td class="column-1"><a href="https://www.reddit.com/r/programming/wiki/faq/#wiki_what_language_reddits_are_there.3F">Reddit Programming languages</a></td><td class="column-2">10</td><td class="column-3">Subreddits for programming languages</td>
</tr>
<tr class="row-5">
	<td class="column-1"><a href="https://redmonk.com/sogrady/2022/10/20/language-rankings-6-22/">Red Monk Programming Language Rankings</a></td><td class="column-2">10</td><td class="column-3">June 2022. Updated every 6 months</td>
</tr>
<tr class="row-6">
	<td class="column-1"><a href="https://survey.stackoverflow.co/2022/#technology">StackOverflow developer survey</a></td><td class="column-2">11</td><td class="column-3">Annually</td>
</tr>
<tr class="row-7">
	<td class="column-1"><a href="https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/#:~:text=As%20of%202022%2C%20JavaScript%20and,55%20percent%20using%20HTML%2FCSS.">Statista most used programming languages 2022</a></td><td class="column-2">11</td><td class="column-3"></td>
</tr>
<tr class="row-8">
	<td class="column-1"><a href="https://www.hackerrank.com/research/developer-skills/2023">Hackerrank Developer skills report 2023</a></td><td class="column-2">12</td><td class="column-3"></td>
</tr>
</tbody>
</table>
<!-- #tablepress-1 from cache -->
<p>There are other programming language lists or surveys but those show what I mean.  No one else has C anywhere that high. Here it&#8217;s in positions 9-12 with an average roughly around 10.5 if you exclude Tiobe or 9.3 if you don&#8217;t.  I think their methodology is flawed and biased by age. Older languages appear to carry more weight.</p>
<p>Never mind C, what about JavaScript? Everyone else has it in first place (except HackerRank who has it in 4th). Tiobe index has it in 7th. Misinformation is defined as “false information that is spread, regardless of intent to mislead.”. Maybe that&#8217;s a bit harsh but that&#8217;s how I regard the Tiobe Index.</p>The post <a href="https://learncgames.com/is-tiobe-index-misinformation/">Is Tiobe Index misinformation?</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">3188</post-id>	</item>
		<item>
		<title>Nice to see an article favouring C</title>
		<link>https://learncgames.com/nice-to-see-an-article-favouring-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nice-to-see-an-article-favouring-c</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Fri, 06 Jan 2023 00:00:23 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3181</guid>

					<description><![CDATA[<p>Toptal.com is a site for recruiting freelances for projects. They have published an article by a developer Daniel Munoz which praises C and shows how it is still quite relevant today. It&#8217;s definitely worth a read. Given the pressure today to move to Rust, Go and even Kotlin, it&#8217;s nice to see someone praising C.  [&#8230;]</p>
The post <a href="https://learncgames.com/nice-to-see-an-article-favouring-c/">Nice to see an article favouring C</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;:34,&quot;href&quot;:&quot;https:\/\/www.toptal.com\/c\/after-all-these-years-the-world-is-still-powered-by-c-programming&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>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3182" src="https://learncgames.com/wp-content/uploads/2023/01/oiudgkhhun0-300x200.jpg" alt="brown wooden letter c decor" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2023/01/oiudgkhhun0-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2023/01/oiudgkhhun0-1024x681.jpg 1024w, https://learncgames.com/wp-content/uploads/2023/01/oiudgkhhun0-768x511.jpg 768w, https://learncgames.com/wp-content/uploads/2023/01/oiudgkhhun0-1536x1021.jpg 1536w, https://learncgames.com/wp-content/uploads/2023/01/oiudgkhhun0.jpg 1600w" sizes="auto, (max-width: 300px) 100vw, 300px" />Toptal.com is a site for recruiting freelances for projects. They have <a title="Link to Toptal article on why C still powers the world" href="https://www.toptal.com/c/after-all-these-years-the-world-is-still-powered-by-c-programming" target="_blank" rel="noopener">published an article</a> by a developer Daniel Munoz which praises C and shows how it is still quite relevant today. It&#8217;s definitely worth a read.</p>
<p>Given the pressure today to move to Rust, Go and even Kotlin, it&#8217;s nice to see someone praising C.  Of course for the games I do C is near perfect.</p>The post <a href="https://learncgames.com/nice-to-see-an-article-favouring-c/">Nice to see an article favouring 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">3181</post-id>	</item>
		<item>
		<title>How to debug programs using SDL</title>
		<link>https://learncgames.com/how-to-debug-programs-using-sdl/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-debug-programs-using-sdl</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 01 Jan 2023 00:00:51 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[fprintf]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3174</guid>

					<description><![CDATA[<p>There&#8217;s nothing worse than a program halting with a simple &#8220;Segmentation fault&#8221; and no idea where or why. It happened to me today working on the 2nd eBook (for Raspberry Pi) and I had to figure out where it was going wrong. In the end it was a really silly bug, I was trying to [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-debug-programs-using-sdl/">How to debug programs using SDL</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;:35,&quot;href&quot;:&quot;https:\/\/www.educba.com\/stderr-in-c&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206111555\/https:\/\/www.educba.com\/stderr-in-c\/&quot;,&quot;redirect_href&quot;:&quot;https:\/\/www.educba.com\/stderr-in-c\/&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 22:25:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-10 08:53:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 20:32:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-17 13:34:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-21 07:08:05&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-24 21:19:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 13:10:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-04 05:12:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-09 21:59:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-15 12:33:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-21 03:40:03&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-24 15:23:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-29 10:24:48&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-01 20:14:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 02:03:12&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-08 11:16:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 14:30:33&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 09:28:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-19 12:07:25&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 12:07:25&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-3176" src="https://learncgames.com/wp-content/uploads/2023/01/fprintf.png" alt="Terminal fprintf output" width="373" height="117" srcset="https://learncgames.com/wp-content/uploads/2023/01/fprintf.png 373w, https://learncgames.com/wp-content/uploads/2023/01/fprintf-300x94.png 300w" sizes="auto, (max-width: 373px) 100vw, 373px" />There&#8217;s nothing worse than a program halting with a simple &#8220;Segmentation fault&#8221; and no idea where or why. It happened to me today working on the 2nd eBook (for Raspberry Pi) and I had to figure out where it was going wrong.</p>
<p>In the end it was a really silly bug, I was trying to load masks but had left the <strong>masks/</strong> folder out of the filename.</p>
<p>How did I find it? I sprinkled a few <strong>fprintf(stderr,&#8221;message&#8221;);</strong> throughout the program changing &#8220;message&#8221; to something appropriate and launched it from a terminal. I&#8217;d thought it was in a function <strong>LoadTextures()</strong> so added a call before and after but you can see that worked and the segmentation fault happened <em>after</em> <strong>LoadTextures()</strong>.</p>
<p>So I added it before and after <strong>LoadMasks()</strong> and my second run it happened before it reached the <strong>After LoadMasks</strong> message.</p>
<p>Note, I used <strong>stderr</strong> as the output path because, unlike <strong>stdout</strong> which is buffered and can be cleared, anything sent to <strong>stderr</strong> appears immediately.  More about this in this <a title="Link to article about stderr" href="https://www.educba.com/stderr-in-c/" target="_blank" rel="nofollow noopener">offsite article</a>.</p>
<p>The <strong>using SDL</strong> part of the title is just to show that you can find bugs even in programs that use SDL.</p>The post <a href="https://learncgames.com/how-to-debug-programs-using-sdl/">How to debug programs using SDL</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">3174</post-id>	</item>
	</channel>
</rss>
