Project management and compiler options
Project management in Pascal is much easier than with C. The compiler knows from the source which units, sources etc. it needs. So the Free PascalIDE does not need a full featured project manager like some C development environments offer. Nevertheless there are some settings in the IDE which apply to projects.
The primary file
Without a primary file the IDE compiles/runs the source of the active window when a program is started. If a primary file is specified, the IDE always compiles/runs this source, even if another source window is active. With the menu item a file dialog can be opened where the primary file can be selected. Only the menu item compiles the active window regardless. This is useful if a large project is being edited, and only the syntax of the current source should be checked.
The menu item restores the default behavior of the IDE, i.e. the ’compile’ and ’run’ commands apply to the active window.
The directory dialog
In the directory dialog, the directories can be specified where the compiler should look for units, libraries, object files. It also says where the output files should be stored. Multiple directories (except for the output directory) can be entered, separated by semicolons. The directories dialog is shown in figure [fig:odirs].
The following directories can be specified:
- EXE & PPU directories
-
Specifies where the compiled units and executables will go. ( on the command line.)
- Object directories
-
Specifies where the compiler looks for external object files. ( on the command line.)
- Library directories
-
Specifies where the compiler (more exactly, the linker) looks for external libraries. ( on the command line.)
- Include directories
-
Specifies where the compiler will look for include files, included with the
{$i }directive. ( or on the command line.) - Unit directories
-
Specifies where the compiler will look for compiled units. The compiler always looks first in the current directory, and also in some standard directories. ( on the command line.)
Remark: For the search path an asterisk (*) as the last directory will include all subdirectories one level deep.
Path substitution variables such as $fpctarget and $fpcversion can be used (section Compiler configuration).
The target operating system
The menu item allows specification of the target operating system for which the sources will be compiled. Changing the target doesn’t affect any compiler switches or directories. It does affect some defines defined by the compiler. The settings here correspond to the option on the command line . A sample compilation target dialog is shown in figure [fig:target]: the actual dialog will show only those targets that the IDE actually supports.
The following targets can be set (the list depends on the platform for which the IDE was compiled):
- Dos (go32v1)
-
This switch will disappear in time as this target is no longer being maintained.
- Dos (go32v2)
-
Compile for DOS, using version 2 of the Go32 extender.
- FreeBSD
-
Compile for FreeBSD.
- Linux
-
Compile for Linux.
- OS/2
-
Compile for OS/2 (using the EMX extender).
- Windows
-
Compile for Windows.
The currently selected target operating system is shown in the menu item in the menu. Initially, this will be set to the operating system for which the IDE was compiled.
Compiler options
The menu allow the setting of options that affect the compilers behavior. When this menu item is chosen, a dialog pops up that displays several tabs.
There are six tabs:
- Syntax
-
Here options can be set that affect the various syntax aspects of the code. They correspond mostly to the
-Soption on the command line (section Compiler configuration). - Code generation
-
These options control the generated code; they are mostly concerned with the
-Cand-Xcommand line options. - Verbose
-
These set the verbosity of the compiler when compiling. The messages of the compiler are shown in the compiler messages window (can be called with ).
- Browser
-
Options concerning the generated browser information. Browser information needs to be generated for the symbol browser to work.
- Assembler
-
Options concerning the reading of assembler blocks (-R on the command line) and the generated assembler (
-Aon the command line) - Processor
-
Here the target processor can be selected.
On each tab page, there are two entry boxes: the first for Conditional defines and the second for additional compiler arguments. The symbols, and arguments, should be separated with semi-colons.
The syntax tab of the compiler options dialog is shown in figure [fig:ocompa].
In the syntax options dialog, the following options can be set:
- Stop after first error
-
when checked, the compiler stops after the first error. Normally the compiler continues compiling till a fatal error is reached. ( on the command line)
- Allow label and goto
-
Allow the use of label declarations and goto statements ( on the command line).
- Enable macros
-
Allow the use of macros ().
- Allow inline
-
Allow the use of inlined functions ( on the command line).
- Include assertion code
-
Include
Assertstatements in the code. - Load kylix compat. unit
-
Load the Kylix compatibility unit.
- Allow STATIC in objects
-
Allow the
Staticmodifier for object methods ( on the command line) - C-like operators
-
Allows the use of some extended operators such as
+=, -=etc. ( on the command line). - Compiler mode
-
select the appropriate compiler mode:
- Free Pascal Dialect
-
The default Free Pascalcompiler mode (
FPC). - Object pascal extensions on
-
Enables the use of classes and exceptions ( on the command line).
- Turbo pascal compatible
-
Try to be more Turbo Pascalcompatible ( on the command line).
- Delphi compatible
-
Try to be more Delphicompatible ( on the command line).
- Macintosh Pascal dialect
-
Try to be Macintosh pascal compatible.
The code generation tab of the compiler options dialog is shown in figure [fig:ocompb].
In the code generation dialog, the following options can be set:
- Run-time checks
-
Controls what run-time checking code is generated. If such a check fails, a run-time error is generated. The following checking code can be generated:
- Range checking
-
Checks the results of enumeration and subset type operations ( command line option).
- Stack checking
-
Checks whether the stack limit is not reached ( command line option).
- I/O checking
-
Checks the result of IO operations ( command line option).
- Integer overflow checking
-
Checks the result of integer operations ( command line option).
- Object method call checking
-
Check the validity of the method pointer prior to calling it.
- Position independent code
-
Generate PIC code.
- Create smartlinkable units
-
Create smartlinkable units.
- Optimizations
-
What optimizations should be used when compiling:
- Generate faster code
-
Corresponds to the
-OGcommand line option. - Generate smaller code
-
Corresponds to the
-Ogcommand line option.
More information on these switches can be found in section Compiler configuration.
The processor tab of the compiler options dialog is shown in figure [fig:ocompf].
In the processor dialog, the target processor can be set. The compiler can use different optimizations for different processors.
The verbose tab of the compiler options dialog is shown in figure [fig:ocompc].
In this dialog, the following verbosity options can be set (on the command line: ):
- Warnings
-
Generate warnings. Corresponds to
-vwon the command line. - Notes
-
Generate notes. Corresponds to
-vnon the command line. - Hints
-
Generate hints. Corresponds to
-vhon the command line. - General info
-
Generate general information. Corresponds to
-vion the command line. - User,tried info
-
Generate information on used and tried files. Corresponds to
-vuton the command line. - All
-
Switch on full verbosity. Corresponds to
-vaon the command line. - Show all procedures if error
-
If an error using overloaded procedure occurs, show all procedures. Corresponds to
-vbon the command line.
The browser tab of the compiler options dialog is shown in figure [fig:ocompd].
In this dialog, the browser options can be set:
- No browser
-
(default) No browser information is generated by the compiler.
- Only global browser
-
Browser information is generated for global symbols only, i.e. symbols defined not in a procedure or function (
-bon the command line) - Local and global browser
-
Browser information is generated for all symbols, i.e. also for symbols that are defined in procedures or functions (
-blon the command line)
Remark: If no browser information is generated, the symbol browser of the IDE will not work.
The assembler tab of the compiler options dialog is shown in figure [fig:ocompe]. The actual dialog may vary, as it depends on the target CPU the IDE was compiled for.
In this dialog, the assembler reader and writer options can be set:
- Assembler reader
-
This permits setting the style of the assembler blocks in the sources:
- AT&T assembler
-
The assembler is written in
AT&Tstyle assembler (-Ratton the command line). - Intel style assembler
-
The assembler is written in
Intelstyle assembler blocks (-Rintelon the command line).
remark that this option is global, but locally the assembler style can be changed with compiler directives.
- Assembler info
-
When writing assembler files, this option decides which extra information is written to the assembler file in comments:
- List source
-
The source lines are written to the assembler files together with the generated assembler (
-alon the command line). - List register allocation
-
The compiler’s internal register allocation/deallocation information is written to the assembler file (
-aron the command line). - List temp allocation
-
The temporary register allocation/deallocation is written to the assembler file. (
-aton the command line). - List node allocation
-
The node allocation/deallocation is written to the assembler file. (
-anon the command line). - use pipe with assembler
-
use a pipe on unix systems when feeding the assembler code to an external assembler.
The latter three of these options are mainly useful for debugging the compiler itself, it should rarely be necessary to use these.
- Assembler output
-
This option tells the compiler what assembler output should be generated.
- Use default output
-
This depends on the target.
- Use GNU as
-
Assemble using GNU
as(-Aason the command line). - Use NASM coff
-
Produce NASM coff assembler (go32v2,
-Anasmcoffon the command line) - Use NASM elf
-
Produce NASM elf assembler (Linux,
-Anasmelfon the command line). - Use NASM obj
-
Produce NASM obj assembler (
-Anasmobjon the command line). - Use MASM
-
Produce MASM (Microsoft assembler) assembler (
-Amasmon the command line). - Use TASM
-
Produce TASM (Turbo Assembler) assembler (
-Atasmon the command line). - Use coff
-
Write binary coff files directly using the internal assembler (go32v2,
-Acoffon the command line). - Use pecoff
-
Write binary pecoff files files directly using the internal writer. (Win32)
Linker options
The linker options can be set in the menu . It permits the specification of how libraries and units are linked, and how the linker should be called. The linker options dialog is shown in figure [fig:olinker].
The following options can be set:
- Call linker after
-
If this option is set then a script is written which calls the linker. This corresponds to the
soption on the command line (). - Only link to static library
-
Only use static libraries.
- Preferred library type
-
With this option, the type of library to be linked in can be set:
- Target default
-
This depends on the platform.
- Dynamic libraries
-
Tries to link in units in dynamic libraries. (option
-XDon the command line.) - Static libraries
-
Tries to link in units in static libraries. (option
-XSon the command line.) - Smart libraries
-
Tries to link in units in smart-linked libraries. (option
-XXon the command line.)
Memory sizes
The memory sizes dialog (reachable via ) permits the entry of the memory sizes for the project. The memory sizes dialog is shown in figure [fig:omemsize].
The following sizes can be entered:
- Stack size
-
Sets the size of the stack in bytes (option
-Cson the command line). This size may be ignored on some systems. - Heap size
-
Sets the size of the heap in bytes; (option
-Chon the command line). Note that the heap grows dynamically as much as the OS allows.
Debug options
In the debug options dialog (reachable via ), some options for inclusion of debug information in the binary can be set; it is also possible to add additional compiler options in this dialog. The debug options dialog is shown in figure [fig:odebug].
The following options can be set:
- Debugging information
-
tells the compiler which debug information should be compiled in. One of the following options can be chosen:
- Strip all debug symbols from executable
-
Will strip all debug and symbol information from the binary. (option
-Xson the command line). - Skip debug information generation
-
Do not generate debug information at all.
- Generate debug symbol information
-
Include debug information in the binary (option
-gon the command line). Please note that no debug information for units in the Run-Time Library will be included, unless a version of the RTL compiled with debug information is available. Only units specific to the current project will have debug information included. - Generate also backtrace line information
-
Will compile with debug information, and will additionally include the
lineinfounit in the binary, so that in case of an error the backtrace will contain the file names and line numbers of procedures in the call-stack. (Option-glon the command line.) - Generate valgrind compatible debug info
-
Generate debug information that can be read with valgrind (a memory checking tool).
- Profiling switches
-
Tells the compiler whether or not profile code should be included in the binary.
- No profile information
-
Has no effect, as it is the default.
- Generate Profile code for gprof
-
If checked, profiling code is included in the binary (option
-pon the command line).
- Use another TTY for Debuggee
-
An attempt will be made to redirect the output of the program being debugged to another window (terminal), whose file name should be entered here.
The switches mode
The IDE allows saving a set of compiler settings under a common name. It provides 3 names under which the switches can be saved:
- Normal
-
For normal (fast) compilation.
- Debug
-
For debugging; intended to set most debug switches on. Also useful for setting conditional defines that e.g. allow including some debug code.
- Release
-
For a compile of the program as it should be released, debug information should be off, the binary should be stripped, and optimizations should be used.
Selecting one of these modes will load the compiler options as they were saved the last time the selected mode was active, i.e. it doesn’t specifically set or unset options.
When setting and saving compiler options, be sure to select the correct switch mode first; it makes little sense to set debug options while the release switch is active. The switches mode dialog is shown in figure [fig:oswitch].
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
