Please login or register.

Login with username, password and session length
Advanced search  


Created for developers of all Amiga camps

Author Topic: Compiler modes  (Read 295 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 31
    • View Profile
Compiler modes
« on: August 05, 2017, 08:01:14 PM »


Which compiler mode should I use?
Depending on that the language seems to behave a bit differently.
Obviously MACPAS is only on Mac.
But what about the others.
To keep it simple, can I just stick to FPC?



  • Newbie
  • *
  • Posts: 9
  • Stealth Ranger
    • View Profile
Re: Compiler modes
« Reply #1 on: August 05, 2017, 10:34:39 PM »

Specifying the compiler mode can be on per-unit basis using the {$MODE <mode>} directive, so you don't have to decide which one to use for the whole project. You can intermix units built with different compiler modes in the same project.

Otherwise it depends on your needs, really. Apart from the obvious extra OOP features enabled in OBJFPC or DELPHI mode, and minor syntax differences, the two major visible changes are:

1., size of the "Integer" type can be either 16bit or 32bit, for the 68k codegenerator it's better if you use one with 32bit, or use the LongInt type explicitly
2., the "String" type can mean either a Shortstring (max. 255 char length, length stored at first byte, allocated on stack) or an Ansistring (unlimited length, zero terminated, allocated on heap), but it's always possible to specify the string type explicitly to avoid confusion.

So the bottom line is, it's pretty much possible to write code which compiles properly in any compiler mode, but as it's still possible to intermix modes in a single project, it's little concern. You have to decide on what you plan to write, and which features you want to use. I primarily use FPC mode, unless I need OOP, when I use ObjFPC mode. Alb42 sometimes uses Delphi mode I think, because he uses Delphi at work too. Free Pascal itself is written in ObjFPC mode, with FPC mode in the low-level parts of the RTL.

I'd say stick to FPC or ObjFPC mode for a start, you can always re-evaluate this decision later if it turns out it didn't work for you for some reason.


  • Full Member
  • ***
  • Posts: 221
  • Programming is an art form that fights back
    • View Profile
Re: Compiler modes
« Reply #2 on: August 07, 2017, 12:37:25 AM »

Chain-Q made a pretty good write-up  :)

It doesn't really matter much which mode you use.

There are 'modes' available such as iso pascal mode. That particular mode is only beneficial when you wish to compile your code with another (iso compatible pascal) compiler or want to compile iso standard pascal code with the Free Pascal compiler.

mode TP is only interesting if you wish to compile old code that was written for/with Turbo and/or Borland Pascal.

Personally i often (and quickly) fall back to using classes/oop so i've learned myself to use mode objfpc by default. For those that would (also) like to be able to compile their code with Delphi, mode Delphi is most probably a must.

I would personally worry more about using platform dependent functionality, in case you wish to create software that runs cross-platform. In case that is of no concern to you, then just go ahead and simply do as it is the best learning curve  ;)

If oyu have questions then please don't hesitate to ask. We've already got a plethora of examples but am sure you are able to come up with something we didn't think off  ;D