Programming => Operating Systems => iPhone/iPad => Topic started by: song shuang on October 22, 2018, 01:58:34 pm
Title: Error: Identifier not found "result"
Post by: song shuang on October 22, 2018, 01:58:34 pm
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,
Title: Re: Error: Identifier not found "result"
Post by: rvk on October 22, 2018, 02:04:29 pm
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.
Title: Re: Error: Identifier not found "result"
Post by: Xor-el on October 22, 2018, 02:07:56 pm
if I remember correctly, the keyword "result" is only recognized in mode ObjFPC and mode Delphi.
Title: Re: Error: Identifier not found "result"
Post by: song shuang on October 22, 2018, 02:19:42 pm
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