Lazarus

Programming => LCL => Topic started by: vfclists on February 27, 2017, 06:21:58 pm

Title: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on February 27, 2017, 06:21:58 pm
I am compiling the vclua project which uses some of the TSynEdit/Highlighter files, using Lazarus 1.6.5 and FPC 3.0.3.

These are the error messages from versions 0.5 and 0.6.1

vclua 0.5 -  32bit:failure, 64bit:failure

error message
Code: Pascal  [Select][+][-]
  1. syneditmarks.pp(1048,35) Error: Illegal type conversion: "TSynEditMarkChangeReasons" to "LongInt"
  2.  


offending code
Code: Pascal  [Select][+][-]
  1. procedure TSynEditMarkChangedHandlerList.Add(AHandler: TSynEditMarkChangeEvent;
  2.   Changes: TSynEditMarkChangeReasons);
  3. begin
  4.   AddBitFilter(TMethod(AHandler), LongInt(Changes));
  5. end;



vclua 0.6.1 -  32bit:success, 64bit:failure

error message
Code: Pascal  [Select][+][-]
  1. SynHighlighterLua.pas(1045,13) Error: Illegal type conversion: "Pointer" to "TRangeState"
  2. SynHighlighterLua.pas(1050,13) Error: Illegal type conversion: "TRangeState" to "Pointer"
  3.  

offending code
Code: Pascal  [Select][+][-]
  1. procedure TSynLuaSyn.SetRange(Value: Pointer);
  2. begin
  3.   fRange := TRangeState(Value);
  4. end;
  5.  
  6. function TSynLuaSyn.GetRange: Pointer;
  7. begin
  8.   Result := Pointer(fRange);
  9. end;
  10.  


I have noticed that the TSyn projects often produce errors and I wonder why, not just with 1.6.2/3.0.2 but even earlier versions.

Could it be down to changes to the code, or could it be due to some the project using some compiler options which are not compatible with the TSynXXX projects?
Title: Re: Errors compling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: marcov on February 27, 2017, 06:56:45 pm
No, I think it is simply the versioning from synedit itself. Lazarus uses synedit as the main editor so editor improvements over time cause synedit mutations.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on February 27, 2017, 07:10:08 pm
No, I think it is simply the versioning from synedit itself. Lazarus uses synedit as the main editor so editor improvements over time cause synedit mutations.

How can I fix this? Does it mean that the version of SynEdit used by Lazarus has moved on from the one in the component directory?

Are the some kind of casts I can use to fix the issues, something I really want to avoid as changing the built in components is a no-no for me? I built my version of Lazarus using fpcupdeluxe.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: Martin_fr on February 27, 2017, 07:35:27 pm
Are the failing sources in vclua, or in SynEdit?
-----------

Some of those errors remind me of things that are 64 or 32 bit only errors.

Quote
"TRangeState" to "Pointer"
I dont know what source causes that, but search through SynEdits own sources.

You may need to typecast via PtrInt or PtrUInt

Pointer(PtrInt(rangestate))

Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on February 27, 2017, 07:57:04 pm
Are the failing sources in vclua, or in SynEdit?
-----------

Some of those errors remind me of things that are 64 or 32 bit only errors.

Quote
"TRangeState" to "Pointer"
I dont know what source causes that, but search through SynEdits own sources.

You may need to typecast via PtrInt or PtrUInt

Pointer(PtrInt(rangestate))

I am compiling with a 64bit build and the errors are in the lazarus components not the project.

Do errors like these which are fixed in the source have to be sent to the bugtracker or are they required only in my local project?
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: Martin_fr on February 27, 2017, 11:07:51 pm
It would be good to get them on the bugtracker.

I just did a build of Lazarus 1.6.4 (entire IDE, incl SynEdit) on 64 bit with fpc 3.0.2.
And the build succeeded.

So I need the exact settings (compile options), to compile SynEdit package, that will trigger this error.

1.6.5 at the moment is near identical to 1.6.4.

I guess 3.0.3 and 3.0.2 have little diff either.
Otherwise it would be desirable to know if it happens with 3.0.2 too (since it could be an fpc issue)

If I cannot reproduce on 1.6.4 / 3.0.2 then I will need to know, if you can.

--------------------
Those errors happen from time to time, because when committing new code it is usually tested with one set of compiler options and for one of 32/64 bit only.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on February 28, 2017, 03:41:08 pm
The error also appears in Lazarus 1.6.4 /FPC 3.0.2 64 bit version.
A closer look at the SynHighlighterLua.pas file show that it belongs to the vclua project itself and is not included in Lazarus

Code: Pascal  [Select][+][-]
  1. $Id: SynHighlighterLua.pas,v 1.1.1.1 2009/01/12 02:34:32 jhansen Exp $
  2.  
  3. You may retrieve the latest version of this file at the SynEdit home page,
  4. located at http://SynEdit.SourceForge.net
  5.  
  6. -------------------------------------------------------------------------------}
  7.  
  8. // 2014/06/10 - added nonkeyword , modified keyword handling (vclua.sf.net)
  9.  

It would be good to get them on the bugtracker.

I just did a build of Lazarus 1.6.4 (entire IDE, incl SynEdit) on 64 bit with fpc 3.0.2.
And the build succeeded.

So I need the exact settings (compile options), to compile SynEdit package, that will trigger this error.

1.6.5 at the moment is near identical to 1.6.4.

I guess 3.0.3 and 3.0.2 have little diff either.
Otherwise it would be desirable to know if it happens with 3.0.2 too (since it could be an fpc issue)

If I cannot reproduce on 1.6.4 / 3.0.2 then I will need to know, if you can.

--------------------
Those errors happen from time to time, because when committing new code it is usually tested with one set of compiler options and for one of 32/64 bit only.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: Martin_fr on February 28, 2017, 04:00:12 pm
what about:
Quote
Code: Pascal  [Select][+][-]
  1.     syneditmarks.pp(1048,35) Error: Illegal type conversion: "TSynEditMarkChangeReasons" to "LongInt"
  2.      

That is part of Lazarus.
But as I said, it did compile for me (on both 32 and 64 bit). That is unless the unit is not compiled when building the IDE.

Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on February 28, 2017, 04:04:51 pm
The error from the 0.5.0 version is in Lazarus its self - \lazarus\components\synedits\syneditmarks.pp
Does this mean that the build process does not actually compile it, or skips it on an error because it not used by any installed components or libraries?

Quote
I am compiling the vclua project which uses some of the TSynEdit/Highlighter files, using Lazarus 1.6.5 and FPC 3.0.3.

These are the error messages from versions 0.5
vclua 0.5 -  32bit:failure, 64bit:failure

error message
Code: Pascal  [Select][+][-]
  1. syneditmarks.pp(1048,35) Error: Illegal type conversion: "TSynEditMarkChangeReasons" to "LongInt"
  2.  


offending code
Code: Pascal  [Select][+][-]
  1. procedure TSynEditMarkChangedHandlerList.Add(AHandler: TSynEditMarkChangeEvent;
  2.   Changes: TSynEditMarkChangeReasons);
  3. begin
  4.   AddBitFilter(TMethod(AHandler), LongInt(Changes));
  5. end;

Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on February 28, 2017, 04:08:34 pm
what about:
Quote
Code: Pascal  [Select][+][-]
  1.     syneditmarks.pp(1048,35) Error: Illegal type conversion: "TSynEditMarkChangeReasons" to "LongInt"
  2.      

That is part of Lazarus.
But as I said, it did compile for me (on both 32 and 64 bit). That is unless the unit is not compiled when building the IDE.

Are you compiling with the current table builds i.e 1.6.2/300/302 or 1.6.4/300/302?

Did you compile it with another projects or the vclua project itself? Perhaps it could be down to some projects settings in vclua which is a dll/so.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: Martin_fr on March 01, 2017, 03:23:57 am
Are you compiling with the current table builds i.e 1.6.2/300/302 or 1.6.4/300/302?

Did you compile it with another projects or the vclua project itself? Perhaps it could be down to some projects settings in vclua which is a dll/so.

I did a full IDE build. Afaik that builds the entire package.
Build with tagged versions 3.0.2, and 1.6.4  (Actually, build with the official 1.6.4 win 64 bit release binaries / the fpc included is build from svn, not taken from the fpc release bin, but that is the case for all past lazarus releases.)

I just compiled a new empty project, to which I added the unit. no problems (on 64 bit). And the unit definitely got compiled, if I put an error in there, then it fails, if I remove it again, then it compiles.

I only tested windows. and intel. Not sure about other targets.
It looks as if for some reason your fpc does not think of LongInt as 32 bit signed integer.
Or some setting affects, the sizeof(set)




Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on March 01, 2017, 08:32:55 am
Are you compiling with the current table builds i.e 1.6.2/300/302 or 1.6.4/300/302?

Did you compile it with another projects or the vclua project itself? Perhaps it could be down to some projects settings in vclua which is a dll/so.

I did a full IDE build. Afaik that builds the entire package.
Build with tagged versions 3.0.2, and 1.6.4  (Actually, build with the official 1.6.4 win 64 bit release binaries / the fpc included is build from svn, not taken from the fpc release bin, but that is the case for all past lazarus releases.)

I just compiled a new empty project, to which I added the unit. no problems (on 64 bit). And the unit definitely got compiled, if I put an error in there, then it fails, if I remove it again, then it compiles.

I only tested windows. and intel. Not sure about other targets.
It looks as if for some reason your fpc does not think of LongInt as 32 bit signed integer.
Or some setting affects, the sizeof(set)

I have attached the source code for the projects. Can you try to see if they will compile successfully on your system?
They are also available at https://sourceforge.net/projects/vclua/files/?source=navbar

I have to add another reply to add the second attachment
 
Title: Re: Errors compiling TSynEdit and TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on March 01, 2017, 08:34:38 am
Second attachment of vclua source
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: Martin_fr on March 01, 2017, 12:45:16 pm
Until I get to look at the project, check your fpc config for
http://www.freepascal.org/docs-html/3.0.0/user/userap1.html
  -CPPACKSET=<y>  <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 and 8 
  -CPPACKENUM=<y>  <y> enum packing: 0, 1, 2 and 4 or DEFAULT or NORMAL 

Also check in the project options "Additions and Overrides", the "Configure Build Lazarus" Dialog (option menu), and of course the SynEdit Package options (or ensure the latter are not changed from svn).

Not tested, but I guess SynEdit will fail with those.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on March 01, 2017, 02:26:00 pm
Until I get to look at the project, check your fpc config for
http://www.freepascal.org/docs-html/3.0.0/user/userap1.html
  -CPPACKSET=<y>  <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 and 8 
  -CPPACKENUM=<y>  <y> enum packing: 0, 1, 2 and 4 or DEFAULT or NORMAL 

Also check in the project options "Additions and Overrides", the "Configure Build Lazarus" Dialog (option menu), and of course the SynEdit Package options (or ensure the latter are not changed from svn).

Not tested, but I guess SynEdit will fail with those.

The -CPPACKSET and -CPPACKENUM are not in the fpc.cfg and all the Lazarus code comes unchanged from SVN. Both 0.5.0 and 0.6.1 compile in Lazarus 1.4.4/2.6.4 32bit. I haven't tried them both on 64 bit Lazarus 1.4.4. I will try that later to see if they will both compile.
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: Martin_fr on March 01, 2017, 03:51:20 pm
I did just build the 6.1 on win 64bit (1.6.4 / 3.0.2) (I did not apply the patch, but that should not have an effect on SynEdit)

There is a warning about the search path. Apparently the project add the path of SynEdit. It should use the package instead.
But that does not seem to be the issue.
(Well actually it could be, it can lead to stale ppu files, make sure you check in your apps output folder for any synedit related ppu, and delete them)

I had to comment the 2 lines in HL-Lua. (it seems the ptruint trick will work here)

I did not get any error in syneditmarks.

-------------
try in an empty project (without the lua code) to use the syneditmarks, and writeln the sizeof TSynEditMarkChangeReasons
It should be 4.
label1.Caption := IntToStr(sizeof(TSynEditMarkChangeReasons));
Title: Re: Errors compiling TSynEdit ad TSynHighligher routines in Lazarus 1.6.2?
Post by: vfclists on March 04, 2017, 11:58:12 pm
I did just build the 6.1 on win 64bit (1.6.4 / 3.0.2) (I did not apply the patch, but that should not have an effect on SynEdit)

There is a warning about the search path. Apparently the project add the path of SynEdit. It should use the package instead.
But that does not seem to be the issue.
(Well actually it could be, it can lead to stale ppu files, make sure you check in your apps output folder for any synedit related ppu, and delete them)

I had to comment the 2 lines in HL-Lua. (it seems the ptruint trick will work here)

I did not get any error in syneditmarks.

-------------
try in an empty project (without the lua code) to use the syneditmarks, and writeln the sizeof TSynEditMarkChangeReasons
It should be 4.
label1.Caption := IntToStr(sizeof(TSynEditMarkChangeReasons));

I have managed to get them both working.

The problem in the 0.5.0 version was fixed by removing SynEdit and RTTI controls from the project path and adding their packages.

Quote
b]error message[/b]
Code: Pascal  [Select][+][-]
  1. syneditmarks.pp(1048,35) Error: Illegal type conversion: "TSynEditMarkChangeReasons" to "LongInt"
  2.  

offending code
Code: Pascal  [Select][+][-]
  1. procedure TSynEditMarkChangedHandlerList.Add(AHandler: TSynEditMarkChangeEvent;
  2.   Changes: TSynEditMarkChangeReasons);
  3. begin
  4.   AddBitFilter(TMethod(AHandler), LongInt(Changes));
  5. end;


I don't understand why removing the package directories from the path and adding the packages themselves to the project should fix those issues.
The .lpr file as this code ad the top. Could the {mode Deplhi} be a factor.
Code: Pascal  [Select][+][-]
  1. library vcl;
  2.  
  3. {$mode Delphi}{$H+}
  4. {$i vcldef.inc}
  5.  
  6. {$R *.res}
  7.  

How could one analyze the code for the reason? What are the circumstances in which compiling the code rather than linking to the precompiled units should cause an error?



The problem in the 0.6.1 version was fixed by using PtrUint.

Code: Pascal  [Select][+][-]
  1. procedure TSynLuaSyn.SetRange(Value: Pointer);
  2. begin
  3.   fRange := TRangeState(PtrUint((Value)));
  4. end;
  5.  
  6. function TSynLuaSyn.GetRange: Pointer;
  7. begin
  8.   Result := Pointer(PtrUint(fRange));
  9. end;
  10.  


TinyPortal © 2005-2018