Résumé
In computer programming, conditional compilation is a compilation technique which results in an executable program that is able to be altered by changing specified parameters. 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 or hardware. Many programming languages support conditional compilation. Typically compiler directives 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 code. There is also a similar proprietary mechanism for adding conditional comments within JScript, known as conditional compilation. 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. 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, which is sometimes called "#ifdef hell.
À propos de ce résultat
Cette page est générée automatiquement et peut contenir des informations qui ne sont pas correctes, complètes, à jour ou pertinentes par rapport à votre recherche. Il en va de même pour toutes les autres pages de ce site. Veillez à vérifier les informations auprès des sources officielles de l'EPFL.