Originally named FPK-Pascal, the Free Pascal compiler is a 32 bit Turbo Pascal compatible Pascal compiler for DOS, Linux, Win32, OS/2 and (based on an older version) the AmigaOS. More operating systems (BeOS and FreeBSD/ELF are in advanced stages of development) are in the works.
The compiler is written in Pascal and is able to compile its own sources. The source files are included.
Free Pascal is modest regarding its minimal system requirements (386-25 Mhz for the Intel version and ideally a 68020 processor for the Motorola version). At least 2 megabytes of RAM are required. To remake the compiler more than 16MB is recommended.
Short history:
FPC's version numbering changed a few times over the years. Versions before 0.99.5 are considered archaic. After the release of 0.99.5 a system in version numbering was introduced, and that system was changed slightly changed after the 1.0 release.
Versioning for versions 0.99.5 - 1.0
Compilers with an even last number are release versions(e.g. 0.99.8, 0.99.10, 0.99.12, 0.99.14 1.0.0)
Compilers and packages with an odd last number are development versions (e.g. 0.99.9, 0.99.11, 0.99.13, 0.99.15)
0.99.5 is an exception to this rule, since 0.99.5 IS a release (a release prior to the introduction of this odd/even system).
Letters behind the version number (0.99.12b, 0.99.5d) indicate release versions with some bugs and problems in the original release (respectively 0.99.12 and 0.99.5) fixed.
Versioning after 1.0
Together with the release of 1.0 the version numbering has been slightly changed, and a system in versioning resembling the Linux kernel's has been introduced. The main difference is that the difference between a release version is now in the second number (1.0.x vs 1.1.x) instead of the third number (0.99.14 vs 0.99.15), and the third number now becomes the patch level, replacing the postfixed letter in the old system.
Development snapshots (which are generated daily) reflect the current status of the compiler. Development versions probably have new features and larger bugs fixed since the last release, but might have some temporary stability drawbacks (which are usually fixed by the next day).
Most support for development snapshots are basically the advise to upgrade to newer snapshot in which the bugs are hopefully fixed. Since version 0.99.8 the stability of the compiler steadily increased and development snapshots are often quite useful for certain categories of users. Ask in the maillists if it is worth the trouble in your case if you're not sure.
The current release version is 1.00 for the OS/2, Linux, Windows and Dos (Go32V2) targets and 0.99.5d for the 680x0 based systems (Amiga and Atari ST). The development versions (snapshots) are numbered 1.1.x at the moment
We advise all users to upgrade to the newest version for their target. (1.0 for intel processors, and 0.99.5d for Motorola)
Free Pascal is available for download from all official mirrors
Because the compiler now supports processors other than the Intel, it is important to take a few precautions so that your code will execute correctly on all processors.
The compiler supports the Delphi OOP. Make sure you use the -S2 or -Sd switches (see the manuals for the meaning of these switches). For a list of Delphi incompabilities also check the manual.
No. Please, don't send us mail about homework, we are no teachers. The Free Pascal development team tries to give good support for the Free Pascal compiler and are trying to always reply to emails. If we get emails like this, this becomes harder and harder.
It works like in Turbo Pascal. The first keyword in the file must be UNIT (not case sensitive). The compiler will generate two files: XXX.PPU and XXX.O. The PPU file contains the interface information for the compiler and the O-file the machine code (an object file, whose precise structure depends on the assembler you used). To use this unit in another unit or program, you must include its name in the USES clause of your program.
A Turbo Vision port, called Free Vision, has progressed nicely lately. It's already very usable, we are even writing an IDE in it. Due to copyrights problem the FreeVision source code is not available at the moment. You can download the IDE from the development page. and get an idea of the look and feel though.
To recompile the system unit, it is recommended to have GNU make installed. typing 'make' in the rtl source directory will then recompile all RTL units including the system unit. You may choose to descend into the directory of your OS (e.g. rtl/go32v2) and do a 'make' there.
It is possible to do all this manually, but you need more detailed knowledge of the RTL tree structure for that.
The latest versions of the Free Pascal Compiler come with an error handling routine which catches the segmentation fault and lets the compiler to exit gracefully. This is reported as an internal error 9999. Please try to reproduce the error and send us a bug report.
(For the curious, IE 9999 is not a specific bug. It is a safety measure which terminates if during compiling a certain condition is not met, which can be caused by several bugs. So if you report the bug, and get IE 9999 later in a different piece or part of sourcecode, it could be a completely different bug. IE 10 is something similar. It is a safety measure that is triggered when the estimated number of registers needed to evaluate an expression proves wrong. Just like IE 9999, two IE 10 problems are often independant of eachother.)
function overloading is implemented, like in C++:
procedure a(i : integer); begin end; procedure a(s : string); begin end; begin a('asdfdasf'); a(1234); end.
You must be careful. If one of your overloaded functions is in the interface part of your unit, then all overloaded functions must be in the interface part. If you leave one out, the compiler will complain with a 'This overloaded function can't be local' message. Overloaded functions must differ in their parameters, it's not enough if their return types are different.
C calling convention is implemented as follows: The compiler pushes the parameters from right to left, but the procedure has to clear the stack. For calling the C function strcmp declare the following:
function strcmp(s1 : pchar;s2 : pchar) : integer;cdecl;external; Since 0.99.5, the older [C]; won't work!
Since 0.99.12, the graph unit is available both for Dos and Linux. Under Dos, it only supported VESA modes though. Since version 0.99.14, a new more system independant graph unit is included (although the only extra supported OS is Win32 and this is only rudimentary support) which also supports standard VGA.
Since version 1.0, we also have a completely platform independent way of selecting resolutions and bitdepths. You are strongly encouraged to use it, because other ways will probably fail on one or other platform. See the documentation of the graph unit for more information.
If you use detect as graphdriver, you will end up with the highest supported bitdepth. Since the graph unit currently only supports up to 16 bits per pixel modes and since this bitdepth is supported by all graphics cards made in at least the last 5 years, you will most likely get a 16 bit mode.
The main problem is that in 16 (and 15, 24, 32, ...) bit modes, the colors aren't set anymore using an index in a palette (the palettized way is called "indexed color"). In these modes, the color number itself determines what color you get on screen and you can't change this color. The color is encoded as follows (for most graphics cards on PC's at least):
This means that either you have to rewrite your program so it can work with this so-called "direct color" scheme, or that you have to use D8BIT as graphdriver and DetectMode as graphmode. This will ensure that you end up with a 256 (indexed) color mode. If there are no 256 color modes supported, then graphresult will contain the value GrNotDetected after you called InitGraph and you can retry with graphdriver D4BIT. Make sure you use the constant names (D8BIT, D4BIT, ...) and not their actual numeric values, because those values can change with the next release! That the very reason why such symbolic constants exist.
The default assembler syntax (AT&T style) is different from the one in Borland Pascal (Intel style).
However, as of version 0.99.0, the compiler supports Intel style assembly syntax. See the documentation for more info on how to use different assembler styles.
A description of the AT&T syntax can be found in the DJGPP FAQ http://www.delorie.com/djgpp/v2faq/faq102.html#Syntax or in Brennan's Guide to Inline Assembly http://www.rt66.com/%7Ebrennan/djgpp/djgpp asm.html. The documentation also contains a chapter where the difference between the Intel and AT&T style assembly is explained.
Or you can use the convertor program at http://rcs.urz.tu-dresden.de/schoenfu/zip/asmtrans.zip .
You can do like in TP, via absolute or mem[]. For larger memory blocks use the dosmemput/dosmemget routines in Go32 unit.
On the Intel version the emulator is automatically loaded by the compiler if you add the following commands to your autoexec.bat:
SET 387=N SET EMU386=C:\PP\BIN\GO32V2\WEMU387.DXE(don't forget to replace the C:\PP with the directory where you installed FPC)
By default Free Pascal allocates only 2MB of RAM for your application. If it just allocated all it could get, people running Windows would have problems as Windows would increase the swap file size to give the program more memory on and on, until the swap file drive would be full.
You can specify the size of the heap with -Chxxxx. The default value is -Ch4000000. Try -Ch10000000, provided you got enough swap space.
However, the heap size doesn't really matter anymore, since the Heap is able to grow: if you've used all the available heap space, the program will try to get more memory from the OS, so the heap is limited to the maximum amount of free memory provided by the OS.
It is only handy if you know you will need at least a certain amount of memory. You can then specify this value using the -Ch parameter, so your program will allocate it at once on startup. This is slightly faster than growing the heap a number of times.
With versions before 0.99.10: if you're under DOS you can use the outport* and inport* procedures of the go32 unit.
Since version 0.99.8, the Port array is supported like in TP, as long as you use the ports unit in your program (not available under Win32).
I/O port access is possible under Linux, but that requires root privileges. Check the manuals for the IOPerm, ReadPort and WritePort procedures. (Unit Linux)
There is a problem with the Dos compiler and Win 95 on computers with less than 16 MB. First set in the properties of the DOS box the DPMI memory size to max value. Now try to start a demo program in the DOS box, e.g. HELLO (starting takes some time). If this works you will be able to get the compiler to work by recompiling it with a smaller heap size, perhaps 2 or 4 MB (option -Chxxxx).
Problems have been reported that the GO32v2 compiler does not run on some OS/2 installations. You can use the native OS/2 compiler (strongly preferred solution) or maybe compile a GO32v1 compiler yourself. However, the GO32v2 version should generally work under OS/2 as well.
The file cwsdpmi.exe is missing in the main directory of the zip archive. The above message pops up if no other DPMI services are available. Such services are for example available in a Dos window of Windows. You can either extract that file from basego32.zip or download it from http://www.brain.uni-freiburg.de/%7Eklaus/cwsdpmi.exe. Put it into the same directory as install.exe and run install again.
This is caused by long file names in some of the .ZIPs of the dosversion. A new installer will be generated that ignores the packages with long file names in it. Currently it is still being tested. Alternatively, one could use the installer from the Win32 1.0 version under NT. This has the additional benefit that the archives with long filenames can be selected and installed too.
The exact cause of this problem is that a NT 4.0 dosbox doesn't support long file names for dos programs. Windows 95,98 and 2000 don't exhibit this problem.
or
You are most probably using an older version of OS/2 (like OS/2 Warp 3.0) and don't have TZ variable in your environment. The easiest solution is to add "SET TZ=..." (e.g. "SET TZ=CET-1CEST,3,-1,0,7200,10,-1,0,10800,3600" for most of western and central Europe) line to your CONFIG.SYS, and restart OS/2. The proper setting for you can be found e.g. using the TZCALC tool from TIME868 package.
In the time between the release of new official versions, you can have a look at and test developer versions (so-called "snapshots"). Be warned though: this is work under progress, so in addition to old bugs fixed and new features added, this may also contain new bugs.
Snapshots are generated automatically each night from the current source at that moment. Sometimes this may fail due to bigger changes not yet fully implemented. If your version doesn't work, try again one or two days later. You're advised not to download the GO32v1 version for Dos, since it's not supported any more.
The latest snapshot can always be downloaded from the development web page.
To install a snapshot, extract the zip archive into the existing program directory of the last official version of Free Pascal (after making a backup of the original of course). You can also extract it into an empty directory and then move the files to the program directory, overwriting existing files. Make sure that you extract the ZIP archive such that the included directory structure remains intact. For example if you use PKUNZIP, use "pkunzip -d" instead of just "pkunzip". Note that snpashots also contain a new RTL which most likely can't be used with the previous release version, so backup your old RTL as well.
The development of the IDE (integrated development environment) is not yet finished. However a working test version of the IDE is available as snapshot. It requires the latest compiler snapshot be installed on top of the current official version for your particular platform (1.00 for GO32v2 or Win32). So if you have not already done that, first install the latest official version (e.g. file dos100.zip or dos100full.zip, you find these in the download section).
Then get and extract the latest snapshot for your platform (e.g. snapshot.zip) into the directory containing the official version. Next, do the same with one of the IDE snapshots. For more details on where to find and how to install a snapshot, please see the previous FAQ item. For additional instructions for required IDE configuration please also read the next FAQ item.
Once you have installed the IDE (see the previous FAQ item), it requires two configuration changes before it can compile. This is due to the fact that the IDE includes its own compiler; it does not use ppc386.exe and thus it also does not use the configuration in the file ppc386.cfg.
Start fp.exe, select Target from the Compile menu and then check GO32v2. Next, choose Directories in the Otions menu and in the line "Unit directories" enter the path to your copy of the rtl directory, usually c:\pp\rtl\go32v2. If you have done everything correct and it still doesn't work, you may have grabbed a snapshot that has a bug; in this case try again one or two days later or ask for help on one of the mailing lists.
There are several reasons and remedies for this:
If you are using 0.99.12: Due to some problems with the binary writer, 0.99.12 wasn't released with smartlinkable RTLs. Smartlinking causes only actually used procedures, functions and constants to be linked in.
You can remedy this by using a development version and creating a smartlinking RTL. See the make cycle faq or use a later release if available (0.99.14 and later do include a smartlinkable RTL). To turn on the generation of smartlinkable units, use the -Cx command line option when compiling your units. To turn on the linking of previously generated smarlinkable units, use the -XX (-XS in 0.99.12 and earlier) command line option when compiling a program.
System (syslinux, sysos2 or syswin32, depending on platform) is Pascal's base unit which is implicitely used in all programs. This unit defines several standard procedures and structures, and must be found to be able to compile any pascal program by FPC.
The location of the system.ppu and syslinux.o files are determined by the -Fu switch which can be specified commandline, but is usually in the ppc386.cfg configuration file.
If the compiler can't find this unit there are three possible causes:
A handy trick can be executing "ppc386 programname -vt", this shows where the compiler is currently looking for the system unit's files. You might want to pipe this through more (Dos, OS/2, Windows) or less (Linux), since it can generate more than one screen information:
Dos, OS/2, Windows: ppc386 programname -vt |more
Linux: ppc386 programname -vt |less
Go to the bugs page
gdb(pas)(w) --directory=<src dirs> myprog.exeNotes:
info line *<address>For example:
info line *0x05bd8