HOME

TheInfoList



OR:

In
computer programming Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
, conditional compilation is a compilation technique which results in an
executable program In computing, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instruction (computer science), instructi ...
that is able to be altered by changing specified
parameters A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
. This technique is commonly used when these alterations to the program are needed to run it on different platforms, or with different versions of required
libraries A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
or hardware. Many
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
s support conditional compilation. Typically
compiler directives In computer programming, a directive or pragma (from "pragmatic") is a language construct that specifies how a compiler (or other translator) should process its input. Directives are not part of the grammar of a programming language, and may vary ...
define or "undefine" certain variables; other directives test these variables and modify compilation accordingly. For example, not using an actual language, the compiler may be set to define "Macintosh" and undefine "PC", and the code may contain: (* System generic code *) if mac != Null then (* macOS specific code *) else if pc != Null (* Windows specific code *) In C and some languages with a similar syntax, this is done using an '#ifdef' directive. A similar procedure, using the name " conditional comment", is used by Microsoft Internet Explorer from version 5 to 9 to interpret
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
code. There is also a similar proprietary mechanism for adding conditional comments within
JScript JScript is Microsoft's legacy software, legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer 11 and older. JScript is implemented as an Active Scripting engine. This means that it can be "plugged in" to OLE Aut ...
, known as conditional compilation.{{cite web , url = http://msdn2.microsoft.com/en-us/library/ahx1z4fs(VS.80).aspx , title = Conditional Compilation , publisher = Microsoft Corporation , access-date = 2011-11-27 , archive-url = https://web.archive.org/web/20080906144358/http://msdn2.microsoft.com/en-us/library/ahx1z4fs(VS.80).aspx , archive-date = 2008-09-06 , url-status = dead


References

Programming language implementation