|This article needs additional citations for verification. (October 2009) (Learn how and when to remove this template message)|
FPC in Cygwin
|Developer(s)||Florian Klämpfl & volunteers|
|Stable release||3.0.0 / November 25, 2015|
|Written in||Object Pascal and Assembly|
|License||GNU General Public License|
Free Pascal Compiler (FPC, formerly named FPK Pascal, for program author Florian Paul Klämpfl, the name changed at the end of 1997) is a compiler for the closely related programming language dialects Pascal and Object Pascal. It is free software, released under the GNU General Public License.
It supports its own Object Pascal dialect, and in varying amounts, the dialects of several other Pascal family compilers, including those of Turbo Pascal, Delphi, and some historic Macintosh compilers. The dialect is selected on a per-unit (module) basis, and more than one dialect can be used to produce one program.
It follows a write once, compile anywhere philosophy, and is available for many CPU architectures and operating systems (see Targets). It supports integrated assembly language and an internal assembler in several dialects.[clarification needed]
- 1 Supported dialects
- 2 History
- 3 The 2.4.x release series
- 4 The 2.6.x release series
- 5 The 3.0.0 release series
- 6 Targets
- 7 Integrated development environments
- 8 Plugins to existing IDEs
- 9 Bundled libraries
- 10 Software produced with Free Pascal
- 11 See also
- 12 References
- 13 External links
Free Pascal adopted the de facto standard dialect of Pascal programmers, Borland Pascal and, later, Delphi. From version 2.0 on, Delphi 7 compatibility has been continuously implemented or improved.
The project has a compilation mode concept, and the developers made it clear that they would incorporate working patches for the standardized dialects of the American National Standards Institute (ANSI) and International Organization for Standardization (ISO), to create a standards-compliant mode.
A small effort has been made to support some of the Apple Pascal syntax, to ease interfacing to Mac OS and OS X. Since the Apple dialect implements some standard Pascal features that Turbo Pascal and Delphi omit, Free Pascal is a bit more ISO-compatible than these.
The 2.2.x release series does not significantly change the dialect objectives beyond Delphi 7, instead they aim for closer compatibility. The project still lacks the Delphi functionality of compiler-supported exporting of classes from shared libraries, which is useful, for example, for Lazarus, which implements packages of components.
As of 2011[update], several Delphi 2006-specific features were added in the development branch, and some of the starting work for the features new in Delphi 2009 (most notably the addition of the
UnicodeString type) has been done. The development branch also features an Objective-Pascal extension for Objective-C (Cocoa) interfacing.
As of version 2.7.1, Free Pascal implemented basic ISO Pascal mode, though many things such as
Put procedure and file buffer variable concept for file handling were still absent.
As of version 3.0.0, ISO Pascal mode is fairly complete, with one remaining bug that's fixed in 3.1.1 afterwards. It has been able to compile standardpascal.org's P5 with no changes.
The early years
Student Florian Paul Klämpfl began developing his own compiler, written in the Turbo Pascal dialect, and produced 32-bit code for the GO32v1 DOS extender, which was used and developed by the DJ's GNU Programming Platform (DJGPP) project at that time.
The initial 32-bit compiler was published on the Internet, and the first contributors joined the project. Later, a Linux port was made by Michael van Canneyt, five years before the Borland Kylix compiler became available.
The DOS port was adapted for use in OS/2 using the Eberhard Mattes eXtender (EMX) which made OS/2 the second supported compiling target. Apart from work of Florian Klämpfl as original author, Daniël Mantione contributed significantly to make this happen and provided the original port of the run-time library to OS/2 and EMX. The compiler improved gradually, and the DOS version migrated to the GO32v2 extender. This culminated in release 0.99.5, which was much more widely used than prior versions, and was the last release aiming only for Turbo Pascal compliance; later releases added a Delphi compatibility mode. This release was also ported to systems using a Motorola 68000 family (m68k) processors.
With release 0.99.8 the Win32 target was added, and a start was made with incorporating some Delphi features. Stabilizing for a non-beta release began, and version 1.0 was released in July 2000. The 1.0.x series was widely used, in business and education. For the 1.0.x releases, the port to 68k CPU was redone, and the compiler produced stable code for several 68k Unix-like and AmigaOS operating systems.
The second generation
During the stabilization of what would become 1.0.x, and more so when porting to the Motorola 68k systems, it was clear that the design of the code generator was far too limited in many ways. The principal problems were that adding processors basically meant rewriting the code generator, and that the register allocation was based on the principle of always keeping three free registers between building blocks, which was inflexible and hard to maintain.
For these reasons, the 1.1.x branched from the 1.0.x main branch in December 1999. At first, changes were mostly clean-ups and rewrite-redesign to all parts of the compiler, and then the code generator and register allocator were rewritten. As a bonus, remaining missing Delphi compatibility was added.
The work on 1.1.x continued slowly but steadily. In late 2003, a working PowerPC port became available, followed by an ARM port in summer 2004, a SPARC port in fall 2004, and an x86-64-AMD64 port in early 2004, which made the compiler available for a 64-bit platform.
In November 2003, a first beta release of the 1.1.x branch was packaged and numbered 1.9.0. These were quickly followed by versions 1.9.2 and 1.9.4; the later introduced OS X support. The work continued with version 1.9.6 (January 2005), 1.9.8 (late February 2005), 2.0.0 (May 2005), 2.0.2 (December 2005), and 2.0.4 (August 2006).
Consolidation: the 2.2.x release series
In 2006, some of the major reworks planned for 2.2, such as the rewrite of the unit system, had not begun, and it was decided to start stabilizing the already implemented features.
Some of the motives for this roadmap change were the needs of the Lazarus project, particularly the internal linker, support for Win64, Windows CE, and OS X on x86, and related features like DWARF. After betas 2.1.2 and 2.1.4, version 2.2.0 was released in September 2007, followed by version 2.2.2 in August 2008 and version 2.2.4 in March 2009.
The 2.2.x series vastly improved support for the ActiveX and Component Object Model (COM) interface, and Object Linking and Embedding (OLE), though bugs were still being found. The delegation to interface using the
implements keyword was partly implemented, but was not complete as of March 2011[update]. Library support for ActiveX was also improved.
Another major highlight was the internal linker for Win32, Win64, and Windows CE, which much improveď linking time and memory use, and make the compile-link-run cycle in Lazarus much faster. The efficiency for smart-linking, or dead code elimination, was also improved.
Minor new features are improved DWARF (2/3) debug format support, and optimizations such as tail recursion, omission of unneeded stack frames and register-based common subexpression elimination (CSE) optimization. A first implementation of generic programming (generics) support is also available, but only experimentally.
The 2.4.x release series
The 2.4.x release series had a less clear set of goals than earlier releases. The unit system rewrite was postponed again, and the branch that became 2.4 was created to keep risky commits from 2.2 to stabilize it. Mostly these risky commits were more involved improvements to the new platforms, Mac PowerPC 64, Mac x86-64, iPhone, and many fixes to the ARM and x86-64 architectures in general, as well as DWARF.
Later, during the 2.2 cycle, a more Delphi-like resource support (based on special sections in the binary instead of Pascal constants) was added. This feature, direly needed by Lazarus, became the main highlight of the branch.
Other more minor points were a memory manager that improved heap manager performance in threaded environments, small improvements in Delphi compatibility such as
OleVariant, and improvements in interface delegation.
On January 1, 2010, Free Pascal 2.4.0 was released, followed on November 13, 2010, by bug fix release 2.4.2, with support for
for..in loops, and
abstract classes, and other changes.
The 2.6.x release series
In January 2012, Free Pascal 2.6 was released. This first version from the 2.6 release series also supports Objective Pascal on OS X and iOS targets and implements many small improvements and bug fixes. In February 2013, FPC 2.6.2 was released. It contains NetBSD and OpenBSD releases for the first time since 1.0.10, based on fresh ports. In March 2014, the last point release in the 2.6 series, 2.6.4, occurred and featured mostly database (fcl-db) updates.
The 3.0.0 release series
Releases for 2015 occurred on 25 August, FPC 3.0.0-rc1, on October 21, FPC 3.0.0-rc2, and on 25 November 2015, 3.0.0.
Its main new features are:
- support for ANSI string with codepages (as in D2009+)
- The ISO 7185 mode has been improved, and can now compile a working P4 with only one or two modifications.
- continuous work on generics.
- better support for Delphi-like syntax, though still far from complete. Generic.* directories are worked on by people, but not in mainline yet.
- generics methods/procedures.
- Newer delphi constructs support
- Type helpers for base types like string and numeric literals
- dotted unit names (a namespace hierarchy for units, but without Java classpath-like 1:1 mapping to filesystem)
- class constructors
- constructors for dynamic arrays.
- Advanced records constructors
- Structured exception handling (SEH) on 32 and 64-bit Windows targets
- New architectures and targets
- ARM hardfloat support and target (ARMHF)
- A start on 64-bit ARM support
- MIPS instruction set
- NetBSD and OpenBSD (x86 and x86_64)
- A 16-bit codegenerator has been added with DOS as primary target (using the Netwide Assembler and the Openwatcom linker) support.
- work is being done on revitalizing the m68k port and related AmigaOS targets.
- The codegenerator has been split in a highlevel and lowlevel part to allow codegeneration for representations that are more highlevel:
- internal linker for DOS: GO32v2
A proof of concept internal linker for Executable and Linkable Format (ELF) is already available.
Other work is done in separate branches, to be merged to development trunk when complete and stable:
- extended RTTI (D2010+)
- anonymous methods
- exploratory work is occurring on dynamic packages
|Processor architecture||Operating system, device||Version 3.0.0||Version 2.6.2||Version 2.6.0||Version 2.4.4||Version 2.4.2||Version 2.4.0||Version 2.2.4||Version 2.0.x||Version 1.0.x|
|i386||DOS (GO32v2 extender)||Yes||Yes||Yes||Yes||Yes||Yes||Yes||Yes||Yes|
|Game Boy Advance||Yes||Yes||Yes||Yes||Yes||Yes||No||No||No|
|Mac OS Classic||Unknown||Unknown||Unknown||Unknown||No||No||Yes||Yes||No|
|SPARC||Solaris||Yes||Yes||Yes||Yes||Yes 32bit only||No||No||No||No|
|Java virtual machine||Java||Yes||No||No||No||No||No||No||No||No|
|MIPS (BE and LE)||Linux||Yes||No||No||No||No||No||No||No||No|
|Atari TOS||No||No||No||No||No||No||No||No||Yeslimited cross-compiler only|
Free Pascal also supports byte code generation for the Java Virtual Machine as of version 3.0.0 and targets both Oracle's Java and Google's Android JVM, although not the full Object Pascal syntax is supported. Free Pascal 3.0.0 also supports ARMHF platforms like the Raspberry Pi, including ARMV6-EABIHF running on Raspbian. MIPS. Work on 64-bit ARM has matured into release support for IOS in 3.0.0 as well. A native ARM Android target has been added, ending the formerly hacked ARM Linux target to generate native ARM libraries for Android. This makes porting Lazarus application to Android (using Custom Drawn Interface) easier. Since FPC 2.6.2, OpenBSD and NetBSD are supported on IA32 and X86_64 architectures. A new target embedded has been added for usage without OS (ARM Cortex M and MIPS mainly). With InstantFPC it is possible to run Pascal programs, which are translated just in time, as Unix scripts or CGI back-end.
Integrated development environments
Like most modern compilers, Free Pascal can be used with an integrated development environment (IDE). Besides independent IDEs there are also plugins to various existing IDEs
Free Pascal's own text mode IDE
Free Pascal has its own text-mode IDE resembling Turbo Pascal's IDE. It is made using the Free Vision framework (also included with Free Pascal), a Turbo Vision clone. In addition to many features of the Turbo Pascal IDE, it has code completion and multiple help files format support (HTML, Microsoft Compiled HTML Help (CHM), Information Presentation Facility (IPF). Instead of using command line tools, the IDE uses its own embedded compiler, based on the same source as the command line compiler, and debugger (using libgdb) to provide its functionality.
Lazarus is the most-popular IDE used by Free Pascal programmers. It looks and feels similar to the Delphi IDE, and can be used to create console and graphical applications, Windows services, daemons, and web applications.
Lazarus provides a cross-platform user interface framework, called Lazarus Component Library (LCL). Graphical applications created with LCL can be ported to another platform via recompiling or cross compiling.
CodeTyphon is a 3rd party distribution of the Lazarus IDE for Windows, Linux, FreeBSD and Solaris. It has already many components pre-installed and aims for a crosscompiling out of the box. The project has been said to have forked from Lazarus and FPC, but despite that still regular synchronizes.
MSEide is another Free Pascal-based IDE for building lightweight applications. MSEgui, like LCL to Lazarus, is the class library that comes with MSEide. It communicates directly with X11 via Xlib on Linux, and Windows API (WinAPI, gdi32) under Windows, with support for multiple document interface (MDI) and visual form inheritance.
Open Sibyl was an effort to retarget the Sibyl (Speed/2 Pascal) IDE for OS/2 and eCS to Free Pascal after Speedsoft released the sources of the Sibyl (Speedpascal) IDE. Functional status and completeness unknown, last snapshot from 2002. Attempts to retarget to Virtual Pascal preceded it.
Megido was an effort to create a cross-platform IDE for Free Pascal. It was discontinued, but paved the way for developing Lazarus and Open Sibyl.
I-Pascal is an Object Pascal IDE plug-in for the IntelliJ IDEA platform. It provides all main features and advanced Pascal code navigation, Free Pascal Compiler integration and other features provided by IDEA.
Plugins to existing IDEs
By far the most used IDE plugins are the XCode plugins that are partially distributed with iOS and OS X versions of FPC. See also OS X Overview with several XCode how to arcticles
Visual Studio: OmniPascal
Eclipse Pascal plugin
Several plugins attempts for Eclipse exist the most recent one is Pascal Plugin for eclipse
Some simple work was done on a plugin for Netbeans
Apart from a compiler and an IDE Free Pascal provides the following libraries:
- Free Pascal Runtime Library (RTL): Basic low-level runtime library for general programming tasks
- Free Component Library (FCL): High-level software component library for general programming tasks
Software produced with Free Pascal
- Cartes du Ciel is a free planetarium program for Linux, OS X and Windows. It maps and labels most constellations, planets, and objects visible by telescope; fully written in Lazarus/FPC; released under GPL.
- Cheat Engine is an open-source memory scanner, hex editor, debugger. It is useful for cheating in computer games. Since version 6.0 it is compiled with Lazarus/FPC.
- Free Pascal is written in Object Pascal and assembly language, and self-compiled.
- Hedgewars: a Worms-like turn based strategy game.
- Lazarus: Free Pascal’s affiliated Delphi-like software package for rapid development of graphical applications.
- Morfik: Morfik WebOS AppBuilder uses Free Pascal to produce the resulting CGI binaries.
- MyNotex is a free software note-taking and notes manager for GNU/Linux.
- Peazip is an open source archiver, made with Lazarus/FPC.
- Pixel Studio FX is an image editor like Photoshop.
- TorChat is moving away from Python, and is being rewritten in Free Pascal and Lazarus.
- QED Solver is software to perform numerical calculations for math, science and engineering applications. It has a simple declarative programming language that allows linear and nonlinear equations to be entered as one would write them. The iOS version is built with an Objective-C front end that is statically linked to the equation solver engine and syntax highlighter that are written in Object Pascal and compiled using Free Pascal.
- fpGUI Free Pascal GUI toolkit – cross platform and 100% custom drawn, implemented in Object Pascal
|Wikimedia Commons has media related to Free Pascal.|
|Wikibooks has a book on the topic of: Pascal Programming|
- Introduction to Free Pascal 2.0 – by Daniël Mantione, with in-depth introduction to the new version and a bit of its development history
- Getting Started with FPC
- FPS –a complete Win32-based IDE for FPC, including debugger (trace, breakpoint and watch windows)
- DevPascal – Win32 based IDE for FPC
- Tabitha – a Windows portable editor for FreePascal
- Morfik – Win32 based IDE for build Ajax-based web applications that uses FPC for compiling back-end server side logic