<?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>standards | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/standards/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>Wed, 10 Mar 2021 19:34:14 +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>standards | 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>My ideas for standards in C programs</title>
		<link>https://learncgames.com/my-ideas-for-standards-in-c-programs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-ideas-for-standards-in-c-programs</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 09 Mar 2021 00:00:22 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[standards]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2848</guid>

					<description><![CDATA[<p>As I&#8217;m somewhat restricted at the moment, bashing away on a 7 year old Toshiba laptop running Ubuntu, I thought I&#8217;d look around for some C games to help keep the blog going. There&#8217;s no shortage of games in C, even those that use SDL2 but what I&#8217;ve found is they can be a real [&#8230;]</p>
The post <a href="https://learncgames.com/my-ideas-for-standards-in-c-programs/">My ideas for standards in C programs</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;:113,&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=3772063&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 11:59:14&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-12 08:09:16&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-03-12 08:09:16&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:114,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3772063&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 11:59:16&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-12 08:09:17&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-03-12 08:09:17&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:115,&quot;href&quot;:&quot;https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Nested-Functions.html&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260116132346\/https:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Nested-Functions.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:59:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 08:09:17&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-03-12 08:09:17&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:116,&quot;href&quot;:&quot;https:\/\/github.com\/git\/git\/blob\/master\/banned.h&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251221081948\/https:\/\/github.com\/git\/git\/blob\/master\/banned.h&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:59:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 08:09:18&quot;,&quot;http_code&quot;:429}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-03-12 08:09:18&quot;,&quot;http_code&quot;:429},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_2850" aria-describedby="caption-attachment-2850" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-2850" src="https://learncgames.com/wp-content/uploads/2021/03/board-3772063_640-300x194.jpg" alt="Follow the rules..." width="300" height="194" srcset="https://learncgames.com/wp-content/uploads/2021/03/board-3772063_640-300x194.jpg 300w, https://learncgames.com/wp-content/uploads/2021/03/board-3772063_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-2850" 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=3772063">Gerd Altmann</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3772063">Pixabay</a></figcaption></figure>
<p>As I&#8217;m somewhat restricted at the moment, bashing away on a 7 year old Toshiba laptop running Ubuntu, I thought I&#8217;d look around for some C games to help keep the blog going. There&#8217;s no shortage of games in C, even those that use SDL2 but what I&#8217;ve found is they can be a real pita to compile.</p>
<p>I guess most are for Linux and SDL but I&#8217;ve found things like the include path for SDL header files is one pain point. VS Code has a <strong>Replace in Files </strong>menu item so it&#8217;s not too difficult to change paths in multiple files.</p>
<p>Another difference I found was putting inline functions in the middle of a function. I didn&#8217;t know you could nest functions that way. A bit of digging found that <a title="Link to gcc extension for nested functions" href="https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html" target="_blank" rel="nofollow noopener">good old gcc allows this</a> as an extension but it&#8217;s definitely not normal C and clang doesn&#8217;t allow it which is what I tend to use.</p>
<h3>My C standards</h3>
<p>So my modest standards for writing C code are, to make life a bit simpler for porting&#8230;</p>
<ol>
<li>Use conditional compilation so you can compile on Windows and Linux. This includes paths to SDL, string print to buffers, MSVC <strong>_s</strong> functions (on Windows). Please compile on both platforms; it&#8217;s real easy to break it!</li>
<li>I&#8217;ll eventually use this so that the timer routines I use will be one set of files that can compile on MSVC/clang.</li>
<li><strong>No nested functions.</strong> Yes I know gcc can do it, but its just unnatural. Use recursion if you must or function pointers but not nesting. If you really want to nest functions, program in Delphi or C#.</li>
</ol>
<p>Other things I&#8217;d like are mostly taste, like putting a comment for every function.</p>
<p>Things that don&#8217;t really matter are whether you put function definitions before <strong>main()</strong> or after. If you put them after then you have to include a definition.</p>
<p>Likewise I don&#8217;t care if you use <strong>#pragma once</strong> or the older compile guards.</p>
<p>It&#8217;s probably a good idea to not call any of the <a title="Link to GitHub banned functions" href="https://github.com/git/git/blob/master/banned.h" target="_blank" rel="nofollow noopener">GitHub banned functions.</a> Remember who owns GitHub! (<em>the same people who added the _s functions in Visual C++/MSVC&#8230;</em>)</p>The post <a href="https://learncgames.com/my-ideas-for-standards-in-c-programs/">My ideas for standards in C programs</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">2848</post-id>	</item>
	</channel>
</rss>
