7.2.1 Things that will not work

Here we give a list of things which are defined/allowed in Turbo Pascal, but which are not supported by Free Pascal. Where possible, we indicate the reason.

  1. Duplicate case labels are permitted in Turbo Pascal, but not in Free Pascal. This is actually a bug in Turbo Pascal, and so support for it will not be implemented in Free Pascal.
  2. In Turbo Pascal, parameter lists of previously defined functions and procedures did not have to match exactly. In Free Pascal, they must. The reason for this is the function overloading mechanism of Free Pascal. However, the -M (see page 107) option overcomes this restriction.
  3. The Turbo Pascal variables MEM, MEMW, MEML and PORT for memory and port access are not available in the system unit. This is due to the operating system. Under dos, both the system and the extender unit (GO32) implement the mem constuct. Under linux, the ports unit implements such a construct for the Ports variable.
  4. Turbo Pascal allows you to create procedure and variable names using words that are not permitted in that role in Free Pascal. This is because there are certain words that are reserved in Free Pascal (and Delphi) that are not reserved in Turbo Pascal, such as: PROTECTED, PUBLIC, PUBLISHED, TRY, FINALLY, EXCEPT, RAISE. Using the -Mtp switch will solve this problem if you want to compile Turbo Pascal code that uses these words (chapter B, page 492 for a list of all reserved words).
  5. The Turbo Pascal reserved words FAR, NEAR are ignored. This is because their purpose was limited to a 16-bit environment and Free Pascal is a 32-bit/64-bit compiler.
  6. The Turbo Pascal INTERRUPT directive will work only on the Free Pascal dos target. Other operating systems do not allow handling of interrupts by user programs.
  7. By default the Free Pascal compiler uses AT&T assembler syntax. This is mainly because Free Pascal uses gnu as. However, other assembler forms are available. For more information, see the Programmer’s Guide.
  8. Turbo Pascal’s Turbo Vision is available in Free Pascal under the name of FreeVision, which should be almost 100% compatible with Turbo Vision.
  9. Turbo Pascal’s ’overlay’ unit is not available. It also isn’t necessary, since Free Pascal is a 32/64-bit compiler, so program size shouldn’t be an issue.
  10. The command line parameters of the compiler are different.
  11. Compiler switches and directives are mostly the same, but some extra exist.
  12. Units are not binary compatible. That means that you cannot use a .tpu unit file, produced by Turbo Pascal, in a Free Pascal project.
  13. The Free Pascal TextRec structure (for internal description of files) is not binary compatible with TP or Delphi.
  14. Sets are by default 4 bytes in Free Pascal; this means that some typecasts which were possible in Turbo Pascal are no longer possible in Free Pascal. However, there is a switch to set the set size, see Programmer’s Guide for more information.
  15. A file is opened for output only (using fmOutput) when it is opened with Rewrite. In order to be able to read from it, it should be reset with Reset.
  16. Turbo Pascal destructors allowed parameters. This is not permitted in Free Pascal: by default, in Free Pascal, Destructors cannot have parameters. This restriction can be removed by using the -So switch.
  17. Turbo Pascal permits more than one destructor for an object. In Free Pascal, there can be only one destructor. This restriction can also be removed by using the -So switch.
  18. The order in which expressions are evaluated is not necessarily the same. In the following expression:
    a := g(2) + f(3);

    it is not guaranteed that g(2) will be evaluated before f(3).

  19. In Free Pascal, you need to use the address @ operator when assigning procedural variables.