[Lazarus] Codetools question

Michael Van Canneyt michael at freepascal.org
Sat Oct 10 13:00:09 CEST 2015



On Sat, 10 Oct 2015, Ondrej Pokorny wrote:

> On 10.10.2015 12:43, Michael Van Canneyt wrote:
>> 
>> 
>> On Sat, 10 Oct 2015, Ondrej Pokorny wrote:
>> 
>>> On 10.10.2015 12:35, Michael Van Canneyt wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> Mainly for Mattias, I suppose:
>>>> 
>>>> The SetString routine in the system unit has become a compiler procedure 
>>>> in 3.0:
>>>> 
>>>> {$ifdef FPC_HAS_CPSTRING}
>>>> Procedure fpc_setstring_ansistr_pansichar(out S : RawByteString; Buf : 
>>>> PAnsiChar; Len : SizeInt; cp: TSystemCodePage); rtlproc; compilerproc;
>>>> {$else}
>>>> Procedure SetString(out S : AnsiString; Buf : PAnsiChar; Len : SizeInt);
>>>> {$endif}
>>>> begin
>>>>   SetLength(S,Len);
>>>> {$ifdef FPC_HAS_CPSTRING}
>>>>   SetCodePage(S,cp,false);
>>>> {$endif}
>>>>   If (Buf<>Nil) then
>>>>     fpc_pchar_ansistr_intern_charmove(Buf,0,S,0,Len);
>>>> end;
>>>> 
>>>> This means the codetools are no longer able to find the SetString 
>>>> declaration.
>>>> 
>>>> Is there any way to fix this kind of things (i.e. find compiler procs) in 
>>>> the code tools ?
>>> 
>>> Yes, see TIdentCompletionTool.GatherPredefinedIdentifiers() in 
>>> IdentCompletionTool.pas
>>> 
>>> Add this line there:
>>>
>>>    AddCompilerProcedure('SetString','out 
>>> S:RawByteString;Buf:PAnsiChar;Len:SizeInt;cp:TSystemCodePage');
>> 
>> Oh cool :-)
>> I didn't know this existed, I keep underestimating the Lazarus IDE ;)
>> How to detect the compiler version ? Because it is only for 3.0+, I 
>> suppose.
>
> I think it is save to assume that Lazarus was compiled with the same FPC 
> version that is also used for the sources in editor. Therefore you can use 
> the same compiler directive:

This is definitely not so :-(
I compile lazarus with 2.6.4, but work with compiler set to 3.0 or even jvm.

That is how I bumped into the problem to begin with... :-)

Michael.




More information about the Lazarus mailing list