 
    
<?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 Archives - Complete, Concrete, Concise</title>
	<atom:link href="https://complete-concrete-concise.com/tag/pragma/feed/" rel="self" type="application/rss+xml" />
	<link>https://complete-concrete-concise.com/tag/pragma/</link>
	<description>Practical Information Without The Bloat</description>
	<lastBuildDate>Sun, 17 Jul 2011 19:07:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Preprocessor – the #pragma Directive</title>
		<link>https://complete-concrete-concise.com/programming/c/preprocessor-the-pragma-directive/</link>
		
		<dc:creator><![CDATA[richardsplanet]]></dc:creator>
		<pubDate>Sun, 17 Jul 2011 19:07:22 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[#pragma]]></category>
		<category><![CDATA[preprocessor]]></category>
		<category><![CDATA[understanding]]></category>
		<guid isPermaLink="false">http://complete-concrete-concise.com/?p=909</guid>

					<description><![CDATA[<p>Behaviour of this preprocessor directive is the same for both C and C++ compilers. Behaviour of this directive is very likely to vary from one compiler vendor to another. Purpose The #pragma directive allows implementation specific control of the compiler. Format #pragma command All preprocessor directives begin with the # symbol. It must be the [&#8230;]</p>
<p>The post <a href="https://complete-concrete-concise.com/programming/c/preprocessor-the-pragma-directive/">Preprocessor – the #pragma Directive</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="c1">
<p>Behaviour of this preprocessor directive is the same for both C and C++ compilers.<br />
Behaviour of this directive is very likely to vary from one compiler vendor to another.</p>
</div>
<h1>Purpose</h1>
<p>The <code>#pragma</code> directive allows implementation specific control of the compiler.</p>
<h1>Format </h1>
<div class="c2">
<p><strong>#pragma</strong> <em>command</em></p>
</div>
<p>All preprocessor directives begin with the <code>#</code> symbol. It must be the first character on the line or the first character on the line following optional white space. </p>
<div class="c4">
<p>Some early compilers flagged an error if <code>#</code> was not the first character on the line.</p>
</div>
<p>Spaces or tabs are permitted between the <code>#</code> and <code>pragma</code>, but not escape characters or other symbols or macros. The preprocessor removes white space and concatenates the <code>#</code> and <code>pragma</code> together.</p>
<p>If anything follows the <code>#pragma</code> directive (other than white space) then the program is malformed.</p>
<p>The following are valid uses:</p>
<pre>#pragma pack(2)
# pragma once
# /* comments are white space */ pragma long_calls</pre>
<p>The following are invalid uses:</p>
<pre>// #\ is not a valid preprocessor directive
# \t pragma pack(2)
// #" is not a valid preprocessor directive
# "" pragma once</pre>
<h1>Use</h1>
<p>All <code>#pragma</code> commands are compiler specific, so you need to consult your compiler documentation for details.</p>
<p>If the <code>#pragma <em>command</em></code> is not recognized, the preprocessor ignores it.</p>
<p>Pragmas are used to pass information to the compiler that cannot be done through the language.</p>
<p>A common use of pragmas is to specify the packing / alignment of data. Normally, a compiler will align data on the processor&#8217;s natural boundary (which is usually the same as the processor&#8217;s bit size). However, for structures with byte defined data, 8-bit alignment may be required. The following shows byte alignment packing using Microsoft C/C++:</p>
<pre>#pragma pack(push) /* save the current packing value */
#pragma pack(1) /* pack on a 1 byte boundary */
struct some_type_with_8_bit_alignment
{
char a;
short b;
long c;
char d;
};
#pragma pack(pop) /* restore the saved packing value */</pre>

<p>The post <a href="https://complete-concrete-concise.com/programming/c/preprocessor-the-pragma-directive/">Preprocessor – the #pragma Directive</a> appeared first on <a href="https://complete-concrete-concise.com">Complete, Concrete, Concise</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
