<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Conditional_compilation</id>
	<title>Conditional compilation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Conditional_compilation"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Conditional_compilation&amp;action=history"/>
	<updated>2026-05-04T18:59:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Conditional_compilation&amp;diff=5463519&amp;oldid=prev</id>
		<title>imported&gt;Ira Leviton: differring→differing - typos.toolforge.org</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Conditional_compilation&amp;diff=5463519&amp;oldid=prev"/>
		<updated>2025-06-19T07:31:16Z</updated>

		<summary type="html">&lt;p&gt;differring→differing - typos.toolforge.org&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{short description|When a compiler produces a program which can change based on given parameters}}&lt;br /&gt;
&lt;br /&gt;
In [[computer programming]], &amp;#039;&amp;#039;&amp;#039;conditional compilation&amp;#039;&amp;#039;&amp;#039; is a [[Compiler|compilation]] technique which results in differing [[executable program]]s depending on [[Parameter (computer programming)|parameters]] specified. This technique is commonly used when these differences in the program are needed to run it on [[Cross-platform|different platforms]], or with different versions of required [[Library (computing)|libraries]] or [[Computer hardware|hardware]].&lt;br /&gt;
&lt;br /&gt;
Many [[programming language]]s support conditional compilation. Typically [[compiler directives]] define or &amp;quot;undefine&amp;quot; certain [[Variable (computer science)|variable]]s; other directives test these variables and modify compilation accordingly. For example, not using an actual language, the compiler may be set to define &amp;quot;Macintosh&amp;quot; and undefine &amp;quot;PC&amp;quot;, and the code may contain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- the following code is not Pascal, but that option makes the highlighting work correctly --&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;pascal&amp;quot;&amp;gt;&lt;br /&gt;
(* System generic code *)&lt;br /&gt;
if mac != Null then&lt;br /&gt;
    (* macOS specific code *)&lt;br /&gt;
else if pc != Null&lt;br /&gt;
    (* Windows specific code *)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In [[C (programming language)|C]] and some languages with a similar syntax, this is done using an [[C preprocessor#Conditional compilation|&amp;#039;#ifdef&amp;#039; directive]].&lt;br /&gt;
&lt;br /&gt;
A similar procedure, using the name &amp;quot;conditional comment&amp;quot;, is used by [[Microsoft Internet Explorer]] from version 5 to 9 to interpret [[HTML]] code. There is also a similar proprietary mechanism for adding conditional comments within [[JScript]], known as conditional compilation.&amp;lt;ref name=&amp;quot;MS2&amp;quot;&amp;gt;{{cite web&lt;br /&gt;
| url       = http://msdn2.microsoft.com/en-us/library/ahx1z4fs(VS.80).aspx&lt;br /&gt;
| title       = Conditional Compilation&lt;br /&gt;
| publisher       = Microsoft Corporation&lt;br /&gt;
| access-date       = 2011-11-27&lt;br /&gt;
| archive-url       = https://web.archive.org/web/20080906144358/http://msdn2.microsoft.com/en-us/library/ahx1z4fs(VS.80).aspx&lt;br /&gt;
| archive-date       = 2008-09-06&lt;br /&gt;
| url-status       = dead&lt;br /&gt;
}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[C Sharp (programming language)|C#]] have preprocessor directives for conditional compilation.&amp;lt;ref&amp;gt;{{cite web |title=Preprocessor directives - C# reference |url=https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation |website=learn.microsoft.com |access-date=31 May 2025 |language=en-us}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
#if DEBUG&lt;br /&gt;
    Console.WriteLine(&amp;quot;Debug version&amp;quot;);&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Rust (programming language)|Rust]] have conditional compilation.&amp;lt;ref&amp;gt;{{cite web |title=Conditional compilation - The Rust Reference |url=https://doc.rust-lang.org/stable/reference/conditional-compilation.html |website=doc.rust-lang.org |access-date=31 May 2025}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;rust&amp;quot;&amp;gt;&lt;br /&gt;
#[cfg_attr(target_os = &amp;quot;linux&amp;quot;, path = &amp;quot;linux.rs&amp;quot;)]&lt;br /&gt;
#[cfg_attr(windows, path = &amp;quot;windows.rs&amp;quot;)]&lt;br /&gt;
mod os;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Criticism==&lt;br /&gt;
&lt;br /&gt;
When conditional compilation depends on too many variables, it can make the code harder to reason about as the number of possible combinations of configuration increases exponentially.&amp;lt;ref name=&amp;quot;icse19&amp;quot;&amp;gt;{{cite conference&lt;br /&gt;
| url= https://www.paulgazzillo.com/papers/icse19nier.pdf&lt;br /&gt;
| title= Conditional Compilation is Dead, Long Live Conditional Compilation!&lt;br /&gt;
| last1= Gazzillo&lt;br /&gt;
| first1= Paul&lt;br /&gt;
| last2= Wei&lt;br /&gt;
| first2= Shiyi&lt;br /&gt;
| date= 2019-05-27&lt;br /&gt;
| conference= 2019 IEEE/ACM 41st International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER)&lt;br /&gt;
| conference-url= https://2019.icse-conferences.org/&lt;br /&gt;
| book-title= ICSE-NIER &amp;#039;19: Proceedings of the 41st International Conference on Software Engineering: New Ideas and Emerging Results&lt;br /&gt;
| publisher= IEEE Press&lt;br /&gt;
| archive-url= https://web.archive.org/web/20221107174330/https://www.paulgazzillo.com/papers/icse19nier.pdf&lt;br /&gt;
| archive-date= 2022-11-07&lt;br /&gt;
| url-status= live&lt;br /&gt;
| location= Montreal, QC, Canada&lt;br /&gt;
| pages= 105–108&lt;br /&gt;
| isbn= 978-1-7281-1758-4&lt;br /&gt;
| doi= 10.1109/ICSE-NIER.2019.00035&lt;br /&gt;
| access-date= 2023-01-21&lt;br /&gt;
| language= en}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;meinicke&amp;quot;&amp;gt;{{cite book |last1=Meinicke |first1=Jens |title=Quality Assurance for Conditional Compilation |date=2017 |url=https://doi.org/10.1007/978-3-319-61443-4_12 |work=Mastering Software Variability with FeatureIDE |pages=131–139 |editor-last=Meinicke |editor-first=Jens |place=Cham |publisher=Springer International Publishing |language=en |doi=10.1007/978-3-319-61443-4_12 |isbn=978-3-319-61443-4 |access-date=2023-01-21 |last2=Thüm |first2=Thomas |last3=Schröter |first3=Reimar |last4=Benduhn |first4=Fabian |last5=Leich |first5=Thomas |last6=Saake |first6=Gunter |editor2-last=Thüm |editor2-first=Thomas |editor3-last=Schröter |editor3-first=Reimar |editor4-last=Benduhn |editor4-first=Fabian}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;se-cc-quality&amp;quot;&amp;gt;{{Cite web |title=compiler - How does conditional compilation impact product quality, security and code complexity? |url=https://softwareengineering.stackexchange.com/questions/405980/how-does-conditional-compilation-impact-product-quality-security-and-code-compl |access-date=2023-01-21 |website=Software Engineering Stack Exchange |language=en}}&amp;lt;/ref&amp;gt; When conditional compilation is done via a [[preprocessor]] that does not guarantee syntactically correct output in the source language, such as the [[C preprocessor]], this may lead to hard-to-debug compilation errors,&amp;lt;ref name=&amp;quot;ifdef-harmful&amp;quot;&amp;gt;{{Cite book |last1=Le |first1=Duc |last2=Walkingshaw |first2=Eric |last3=Erwig |first3=Martin |title=2011 IEEE Symposium on Visual Languages and Human-Centric Computing (VL/HCC) |chapter=#ifdef confirmed harmful: Promoting understandable software variation |date=2011-09-18 |url=https://ieeexplore.ieee.org/document/6070391 |pages=143–150 |doi=10.1109/VLHCC.2011.6070391|isbn=978-1-4577-1246-3 }}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;so-avoid-ifdef&amp;quot;&amp;gt;{{Cite web |title=conditional compilation - Why should #ifdef be avoided in .c files? |url=https://stackoverflow.com/questions/1851181/why-should-ifdef-be-avoided-in-c-files |access-date=2023-01-21 |website=Stack Overflow |language=en}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;do-dont-cc&amp;quot;&amp;gt;{{Cite web |title=c++ - Dos and Don&amp;#039;ts of Conditional Compile |url=https://stackoverflow.com/questions/4469645/dos-and-donts-of-conditional-compile |access-date=2023-01-21 |website=Stack Overflow |language=en}}&amp;lt;/ref&amp;gt; which is sometimes called &amp;quot;#ifdef hell.&amp;quot;&amp;lt;ref name=&amp;quot;preschern&amp;quot;&amp;gt;{{Cite conference |last=Preschern |first=Christopher |title=Proceedings of the 24th European Conference on Pattern Languages of Programs |chapter=Patterns to escape the #ifdef hell |date=2019-07-03 |url=http://preschern.azurewebsites.net/2019-os-specific-code.pdf |location=New York, NY, USA |publisher=Association for Computing Machinery |pages=1–12 |doi=10.1145/3361149.3361151 |isbn=978-1-4503-6206-1 |archive-url=https://web.archive.org/web/20221221151021/http://preschern.azurewebsites.net/2019-os-specific-code.pdf| archive-date=2022-12-21|url-status=live}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;ifdef-hell&amp;quot;&amp;gt;{{Cite web |title=Living in the #ifdef Hell |url=http://www.cqse.eu/en/news/blog/living-in-the-ifdef-hell/ |access-date=2023-01-21 |website=www.cqse.eu |date=28 October 2015 |language=en-GB| archive-url=https://web.archive.org/web/20221128024445/https://www.cqse.eu/en/news/blog/living-in-the-ifdef-hell/ |archive-date=2022-11-28 |url-status=live}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming language implementation]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Ira Leviton</name></author>
	</entry>
</feed>