Изменения

Материал из Chaotic Onyx
Перейти к навигацииПерейти к поиску
1222 байта добавлено ,  12:20, 14 ноября 2015
Строка 139: Строка 139:       −
===Conditional Compilation===
+
===Условная компиляция===
   −
The preprocessor can be used to skip sections of code conditionally. The condition usually depends on the existence or value of other macros. In this way you can turn on or off features in the code by configuring a few macro definitions at the top of the project.
+
Препроцессоры могут быть использованы для пропуска части кода по заданным усолвиям, которые определяются наличием или значением используемых макросов. Таким образом вы сможете управлять какими-либо добавочными настройками(фичами), размещая условия компиляции в начале кода.
 
+
<!--The preprocessor can be used to skip sections of code conditionally. The condition usually depends on the existence or value of other macros. In this way you can turn on or off features in the code by configuring a few macro definitions at the top of the project.-->
The commands for conditionally compiling code are described in the following sections.
      +
Вот данные макросы условий для компиляции.
    
====#ifdef====
 
====#ifdef====
   −
The #ifdef command compiles the code which follows only if the specified macro has been defined. The section is terminated by the #endif command.
+
Команда #ifdef разрешает компилировать последующий код, только если определённому макросу было задано определённое значение. Выполнение данной команды завершается оператором #endif
 +
<!--command compiles the code which follows only if the specified macro has been defined. The section is terminated by the #endif command.-->
    
#ifdef Macro
 
#ifdef Macro
//Conditional code.
+
//Условие для дальнейшего выполнения кода.
 
#endif
 
#endif
There is also a #ifndef command which has the opposite effect. The code that follows is only compiled if the macro is not defined.
+
Также существует команда #ifndef - она срабатывает если значение определённого макроса не было задано.
 +
<!--There is also a #ifndef command which has the opposite effect. The code that follows is only compiled if the macro is not defined.-->
   −
The DEBUG macro is sometimes used to turn on certain debugging features in the code. The following example demonstrates this technique.
+
Например макрос DEBUG можно включать для определённого участка кода:
 +
<!--The DEBUG macro is sometimes used to turn on certain debugging features in the code. The following example demonstrates this technique.-->
    
#ifdef DEBUG
 
#ifdef DEBUG
Строка 185: Строка 188:  
#endif
 
#endif
 
Since DM allows comments to be nested (one inside another) it is also possible to accomplish the same thing by putting /* */ around the disabled code. It is a C programmer's habit to use the #if command because many C compilers get confused by nested comments.
 
Since DM allows comments to be nested (one inside another) it is also possible to accomplish the same thing by putting /* */ around the disabled code. It is a C programmer's habit to use the #if command because many C compilers get confused by nested comments.
      
===#error===
 
===#error===
470

правок

Навигация