Sign in Join
Wiki copytemporary

IDE directives

English · Español · Français

Overview

IDE directives are similar to compiler directives: a special kind of comment placed in your source code. They are enclosed by curly brackets with an opening percentage sign. For example:

pascal
{%H-}

The compiler sees them simply as comments which it ignores. The IDE uses these directives to store source-specific information which is independent of project and session.

Hide one hint, note or warning

To hide a single hint, note or warning you use the following IDE directive:

pascal
procedure DoSomething({%H-}NotUsed: char);
begin

end;

This will suppress the line in the Lazarus Messges window that otherwise would report

text
Hint: Parameter "NotUsed" not used

The compiler still issues the Hint, but the {%H-} IDE directive causes the IDE to filter the Hint out of the Messages view.

Note: You can right click on a hint in the message window and choose the context menu option "Hide message via directive" to insert the directive automatically.

This feature was introduced in Lazarus 0.9.29.

File encoding

You can specify what encoding the IDE should use for a source file by adding a BOM or an encoding directive at the very start of a source file:

pascal
{%encoding CP1250}

See the unit lcl/lconvencoding.pas for all possible values.

Run/Build file

The IDE can run and build single files instead of projects. The parameters for building/running a file are stored as IDE directives within the file itself.

See Configure Build File.

Other IDE Directives

Reading / finding IDE directives

The codetools unit basiccodetools contains several functions for reading IDE directives:


From the Free Pascal wiki, page "IDE directives", as it stood on 2020-02-17 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .

Edited on wiki.freepascal.org by 6 people, 2010–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
Mattias2New page: =Overview= IDE directives are similar to compiler directives as they are special comments in the source. For example: <Delphi> {%H-} </Delphi> For the compiler they are simple comments ...
Mattias2Overview
Mattias2Run/Build file
Mattias2Hide one hint, note or warning
VincentText replace - "Delphi>" to "syntaxhighlight>" (minor)
Jwdietrich
Mattias2Run/Build file
Mattias2Run/Build file
Mattias2Reading / finding IDE directives
HowardPCOverview (minor)
HowardPCHide one hint, note or warning (minor)
HowardPCHide one hint, note or warning (minor)
HowardPCOther IDE Directives (minor)
Mattias2Other IDE Directives
E-ric (minor)
Mattias2Run/Build file
Mattias2Run/Build file
Mattias2Run/Build file
Mattias2Run/Build file
TrevFixed syntax highlighting; deleted category included in page template (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.