# Code Generation Preferences Page

This page of the Preferences dialogue box is used to customise the source code emitted by the code generator when creating test compilations and when outputting units.

The page is accessed by selecting the Tools | Preferences menu item then clicking on Code Generation in the list on the left of the window.

Note: This page is not used to modify the style of the source code: use the Code Formatting page for that.

The Code Generator can be configured to generate `$WARN` compiler directives to switch specified warning messages on or off. These directives are supported by Delphi 6 and later. Free Pascal is not supported.

To enable this facility you must check the Emit $WARN directives check box.

The warnings for which compiler directives are to be generated are those listed in the list view control situated below the check box. Warnings are identified by the text in the Symbol column. These symbols must be valid parameters for Delphi's `$WARN` directive. Since new symbols have been introduced in different versions of Delphi, the minimum version of the compiler that supports the warning must also be specified. This is shown in the Min. Compiler column of the list view. The version number is that specified by Delphi's CompilerVersion constant. Finally, whether a warning is switched on or off is shown in the State column.

The list view can be sorted on the contents of any of the columns by clicking the appropriate column header. Clicking the same column header again reverses the sort. The header of the sorted column displays an indicator showing the sort direction.

New symbols can be added and existing symbols updated or deleted by using the controls below the list view, as follows:

- Add a symbol
  Enter the symbol name in the Symbol edit control, specify the earliest compiler version that supports it in the Min. Compiler edit control and specify whether the `$WARN` directive will switch the warning on or off by selecting the appropriate Warning State radio button. Click the Add button to add the symbol to the list. If the Add button remains disabled check that the compiler version is valid and that the symbol name does not already exist in the list view.
- Delete a symbol
  Select the required symbol in the list view then click the Delete button. The symbol will be removed from the list.
- Update a symbol
  Select the symbol to be updated from the list view. It's details will be copied into the Symbol and Min. Compiler edit controls and the appropriate Warning State radio button will be selected. Change the details as required then click the Update button. The changes will be reflected in the list view. If the entered information is not valid then the Update button will be disabled.

The Pre-defined button next to the Min. Compiler edit control is provided to make it easier to choose the minimum compiler version. Clicking the button drops down a menu which displays the names of some Delphi compilers. Choosing a compiler will enter the correct version number in the edit control. Note: The earliest supported compiler version is 14.0.

The Preview button at the top right of the page displays the source code that will be emitted by the code generator.

The Restore Defaults button discards the current list of `$WARN` directives and replaces it with a default set.