Forum > iPhone/iPad
Error: Identifier not found "result"
(1/1)
song shuang:
Hi,
Maybe a simpler question. :D
two unit:
Library foo;
uses
ctypes, math, func;
function GetEeprom(src: pcint32):cint; cdecl;
begin
GetEeprom := getsum(src);
end;
exports
GetEeprom;
begin
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);
end.
unit func;
interface
uses SysUtils, Variants, Classes;
function getsum(src:pointer):integer;
implementation
function getsum(src:pointer):integer;
begin
result := 88;
end;
end.
command line:
ppcx64-3.0.5 -Tiphonesim -XR/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -Cn foo.pas -FU./sim -Fu./mysrc
Free Pascal Compiler version 3.0.5 [2017/11/26] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Darwin/iPhoneSim for x86_64
Compiling foo.pas
Compiling ./mysrc/func.pas
func.pas(13,3) Error: Identifier not found "result"
func.pas(17) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
why the keywords of pascal ,"result" can not be identified?
Thanks for your help!
Best Regards,
rvk:
If you don't specify a mode it will compile with {$mode fpc}
And FPC-mode does not recognize Result as result for a function.
You can read on this page the Result is only recognized by objfpc and delphi modes.
https://www.freepascal.org/docs-html/3.0.2/ref/refse90.html
So either specify the mode in the source:
{$mode objfpc} // or other mode
Or specify it on the command line and add -Mobjfpc to the parameters.
Xor-el:
if I remember correctly, the keyword "result" is only recognized in mode ObjFPC and mode Delphi.
See the corrected code.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---library lib; {$mode objfpc}{$H+} uses ctypes, Math, func; function GetEeprom(src: pcint32): cint; cdecl; begin GetEeprom := getsum(src); end; exports GetEeprom;begin SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);end.end.
and unit func
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit func; {$mode objfpc}{$H+} interface uses SysUtils, Variants, Classes; function getsum(src: pointer): integer; implementation function getsum(src: pointer): integer;begin Result := 88;end; end.
Thaddy:
Yes, but you can also do this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit xxx;{$modeswitch result}
song shuang:
thank for rvk!
i has been looked for a method to create a static library for ios for some days.
test it successful on iphone sim,Not yet test in real iphone.
------
ar -q paslib.a `grep "\.o$" link.res`
ranlib paslib.a
Navigation
[0] Message Index