<?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>linux | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/linux/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, 15 Dec 2025 11:13:54 +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>linux | 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>Linux challenges with the Flutter game</title>
		<link>https://learncgames.com/linux-challenges-with-the-flutter-game/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-challenges-with-the-flutter-game</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 15 Dec 2025 11:11:59 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Dart]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3482</guid>

					<description><![CDATA[<p>The architecture of this is all Flutter and Dart running on a Ubuntu Linux box. There are two pure Dart programs- one to create the game setup and one to do the processing. The first is run manually, the second by crontab. Then there&#8217;s the Flutter web app. The Flutter web app has to read [&#8230;]</p>
The post <a href="https://learncgames.com/linux-challenges-with-the-flutter-game/">Linux challenges with the Flutter game</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<figure id="attachment_3483" aria-describedby="caption-attachment-3483" style="width: 500px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="wp-image-3483 size-full" src="https://learncgames.com/wp-content/uploads/2025/12/tuxandFlutter.png" alt="Tux and Flutter having a tussle" width="500" height="273" srcset="https://learncgames.com/wp-content/uploads/2025/12/tuxandFlutter.png 500w, https://learncgames.com/wp-content/uploads/2025/12/tuxandFlutter-300x164.png 300w" sizes="(max-width: 500px) 100vw, 500px" /><figcaption id="caption-attachment-3483" class="wp-caption-text">Generated by Gemini</figcaption></figure>
<p>The architecture of this is all Flutter and Dart running on a Ubuntu Linux box. There are two pure Dart programs- one to create the game setup and one to do the processing. The first is run manually, the second by crontab. Then there&#8217;s the Flutter web app.</p>
<p>The Flutter web app has to read and write files from the file system which of course it can&#8217;t do directly. I&#8217;ve created a backend of sorts using PHP.  There&#8217;s an API; it works but not without issues. If you&#8217;re calling a PHP script from a Flutter app, what is the URL?  It depends.</p>
<p>Say the URL is /file?params where I&#8217;ve modified .htaccess to pass /file urls onto a PHP script.</p>
<p>If I want to test this on the box in a browser I have to call <em>localhost/file?params</em> but in a Dart program running on the box it just calls<em> /file?params</em>.</p>
<p>The next problem is where are the game files stored. The setup program doesn&#8217;t really care. Any location will do so long as it doesn&#8217;t need to run elevated.  But the web app is limited to /var/www/html &#8211; it&#8217;s running under Apache on a linux box. In the end I created a folder under /var/www/game and each game is stored under there. PHP can read mostly anywhere, not just in /var/www/html and this provide a little extra security.</p>
<p>However there&#8217;s the not-so slight issue of permissions. The setup program runs under my login &#8211; call it <em>user</em>. So files are created owned by <em>user</em> <em>user</em>. The web app runs under <em>www-data</em> so to keep things simple, I&#8217;ve set permissions to <em>user:www-data</em> so both can access it. It&#8217;s a bit of a faff.</p>
<p>Here&#8217;s a tip. If you are developing a Flutter web app, develop it on Linux and do development as a Linux app. It&#8217;s far quicker building and launching a Linux app than it is the web app.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/linux-challenges-with-the-flutter-game/">Linux challenges with the Flutter game</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">3482</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 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="(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>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 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>Identifying a Linux system in code</title>
		<link>https://learncgames.com/identifying-a-linux-system-in-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=identifying-a-linux-system-in-code</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 18 Apr 2020 23:00:54 +0000</pubDate>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[Source code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[code]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=412</guid>

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

int main(void) {

   struct utsname buffer;

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

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

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

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

					<description><![CDATA[<p>I&#8217;m slowly working my way through 30 odd examples of C code that I wrote for the first 20 chapters in my Ebook., And finding odd compile errors. Here&#8217;s an example. I&#8217;ve rewritten my stopWatch object for high-precision timing. This is the header. #include struct _stopWatch { struct timespec start; struct timespec stop; } stopWatch; [&#8230;]</p>
The post <a href="https://learncgames.com/the-joys-of-linux-c-compilation/">The joys of Linux C Compilation</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>I&#8217;m slowly working my way through 30 odd examples of C code that I wrote for the first 20 chapters in my Ebook., And finding odd compile errors. Here&#8217;s an example.</p>
<p>I&#8217;ve rewritten my stopWatch object for high-precision timing. This is the header.</p>
<pre><code class="language-c" data-line="">#include 

struct _stopWatch {
  struct timespec start; 
  struct timespec stop;
} stopWatch;

typedef struct _stopWatch stopWatch;

void startTimer(stopWatch *timer);
void stopTimer(stopWatch *timer);
double diff(stopWatch *timer);</code></pre>
<p>It won&#8217;t compile, and keeps on complaining that<em> timespec is an incomplete type</em>. I saw one solution which was to redefine timespec like this:</p>
<pre><code class="language-c" data-line="">struct timespec {
  time_t tv_sec; /* seconds */
  long tv_nsec; /* nanoseconds */
};</code></pre>
<p>But that got Clang wound up about timespec redefined errors. I searched and searched and eventually found the answer. Instead of</p>
<pre><code class="language-c" data-line="">#include &lt;time&gt;</code></pre>
<p>Use this as well</p>
<pre><code class="language-c" data-line="">#include &lt;time&gt; 
#include &lt;linux/time.h&gt;</code></pre>
<p>Simple when you know how!</p>The post <a href="https://learncgames.com/the-joys-of-linux-c-compilation/">The joys of Linux C Compilation</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://learncgames.com/the-joys-of-linux-c-compilation/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">87</post-id>	</item>
	</channel>
</rss>
