<?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>#pragma once | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/pragma-once/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Fri, 26 Jun 2020 13:02:35 +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>#pragma once | 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>Should you use #pragma once?</title>
		<link>https://learncgames.com/should-you-use-pragma-once/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=should-you-use-pragma-once</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 01 Jul 2020 23:00:07 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[#pragma once]]></category>
		<category><![CDATA[guard]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=914</guid>

					<description><![CDATA[<p>The traditional way of using an include guard is to put all of the header inside a #ifdef like this. #ifndef hr_time #define hr_time #include &#60;linux/time.h&#62; #include // rest of code here #endif However the modern way is to put this at the top of the header file. #pragma once And this seems supported by [&#8230;]</p>
The post <a href="https://learncgames.com/should-you-use-pragma-once/">Should you use #pragma once?</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img fetchpriority="high" decoding="async" class="alignleft size-medium wp-image-916" src="https://learncgames.com/wp-content/uploads/2020/07/pragma-300x220.png" alt="Pragma as found by google image search" width="300" height="220" srcset="https://learncgames.com/wp-content/uploads/2020/07/pragma-300x220.png 300w, https://learncgames.com/wp-content/uploads/2020/07/pragma-768x564.png 768w, https://learncgames.com/wp-content/uploads/2020/07/pragma.png 972w" sizes="(max-width: 300px) 100vw, 300px" />The traditional way of using an include guard is to put all of the header inside a #ifdef like this.</p>
<p><code class="language-c" data-line=""></code></p>
<pre><code class="language-c" data-line="">#ifndef hr_time
  #define hr_time
  #include &lt;linux/time.h&gt;
  #include 

// rest of code here
#endif</code></pre>
<p><code class="language-c" data-line=""></code></p>
<p>However the modern way is to put this at the top of the header file.</p>
<pre><code class="language-c" data-line="">#pragma once</code></pre>
<p>And this seems supported by most compilers I&#8217;ve tried. Certainly Visual Studio C/C++, gcc and clang all work.</p>
<p>In fact when you add a new file and choose <em>header</em> in Visual Studio, it put the <strong>#pragma once</strong> in automatically for you!</p>
<p>Given that those three C compilers are the main ones I use, I much prefer this pragma and use it.  But I would be interested in hearing of any C compilers that don&#8217;t  use it.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/should-you-use-pragma-once/">Should you use #pragma once?</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">914</post-id>	</item>
	</channel>
</rss>
