Author Topic: Identifier not found "result" for Free Pascal Compiler version 2.6.4 [2014/02/26  (Read 5770 times)


  • New member
  • *
  • Posts: 7
Hi I've tried to find the solution for this problem, but it's largely not understandable due to my very brief knowledge in programming. I've read through some of the response to this topic. Here are some fragments of what I read:

This message is even more a better help for beginners: "are you in the right
syntax-mode? only ObjFPC (-MObjfpc) or Delphi (-Mdelphi) mode supports a
function result"

If the identifyer that was not found is named "result" then a compiler
message "are you in the right syntax-mode? only ObjFPC (-MObjfpc) or Delphi
(-Mdelphi) mode supports a function result" is shown.

What should I do? Do I need to install the ObjFPC/Deplhi?
Please give me full instructions to solve this problem.
As I have tried several functions from different files. All of them return identifier not found "result".


  • Hero Member
  • *****
  • Posts: 542
The keyword "result" is accepted by the compiler only for some compilation modes. And the by-default mode for the compiler (i.e. if you do not indicate one by yourself) doesn't accept it.

There are 3 solutions for your problem, to indicate a compatible compilation mode for your programs. The second one is the simplest (for a simple program), unless you are using the Lazarus IDE (in this case, choose the 3rd one):

1/ If you compile your programs by calling the compiler yourself, you'll have to add a "compatible" mode for the compilation (ObjFPC or Delphi).

For instance:
fpc  -MObjFPC  project1.pas

(instead of just fpc project1.pas)

2/ Or, you can select the "compatible" mode directly into the source of your program.

For instance, hereafter a very basic free pascal program accepting the keyword "result" (please note the additional line "{$mode objfpc}", at the beginning of the source code for the concerned unit):
Code: [Select]
program project1;

{$mode objfpc}

function Test(): string;
  result:='A string...';


3/ Or, if you are using the Lazarus IDE, the by-default mode for your whole project (i.e. all its units) may be changed into the project options (i.e. the compilation mode indication "job" is done by the IDE).

Main Lazarus IDE menu: Project -> Project options... -> Compiler Options -> Parsing -> Syntax mode.

If it's not already the case, choose the "Object Pascal" or the "Delphi" mode.
« Last Edit: May 14, 2015, 02:03:05 pm by ChrisF »


  • New member
  • *
  • Posts: 7
my result for your option 1:

hilarys-MBP:CircleArea hilarylaw$ fpc  -MObjFPC CircleArea.pas
Free Pascal Compiler version 2.6.4 [2014/02/26] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Darwin for i386
Compiling CircleArea.pas
Assembling (pipe) CircleArea.s
Linking CircleArea
25 lines compiled, 2.4 sec
hilarys-MBP:CircleArea hilarylaw$

thx for that!