Recent

Author Topic: Is Mac carbon broken..  (Read 7507 times)

Josh

  • Hero Member
  • *****
  • Posts: 1270
Is Mac carbon broken..
« on: June 16, 2019, 06:29:53 pm »
Hi

I have an old app that must stay on carbon for s while yet; as it is run on old mac's.

I downloaded latest trunk of fpc and laz for x64 cocoa, and the cross compiler for i386 darwin.

If I try to compile any project; even a blank form I get error

carbongdiobjects.pp(2072,45) Error: Incompatible type for arg no. 1: Got "Array[0..1] Of Single", expected "TCarbonDashes"

Code: [Select]
case FStyle of
    PS_DASH:
      begin
        ADashes := GetDashes(CarbonDashStyle);
        CGContextSetLineDash(ADC.CGContext, 0, @ADashes[0], Length(ADashes));
      end;
    PS_DOT:
      begin
        ADashes := GetDashes(CarbonDotStyle);
        CGContext


Any ideas
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Is Mac carbon broken..
« Reply #1 on: June 17, 2019, 01:50:55 am »
Josh, I used fixes (rather than trunk) a few days ago to build the carbon version of my app. All good.

As its likely no one is updating anything to do with Carbon anymore, there would seem very little point in you using trunk anyway (?)

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Is Mac carbon broken..
« Reply #2 on: June 17, 2019, 09:02:48 am »
Josh, I used fixes (rather than trunk) a few days ago to build the carbon version of my app. All good.

As its likely no one is updating anything to do with Carbon anymore, there would seem very little point in you using trunk anyway (?)
Only because Carbon is no longer going to be supported on new Macs doesn't mean that Lazarus should stop supporting Carbon. For older Macs that might still be necessary.

@josh: maybe best report a bug.

Thaddy

  • Hero Member
  • *****
  • Posts: 14166
  • Probably until I exterminate Putin.
Re: Is Mac carbon broken..
« Reply #3 on: June 17, 2019, 09:17:31 am »
Maybe something like this, note I eddited the code later:
Code: Pascal  [Select][+][-]
  1. type PCarbonDashes = ^TCarbonDashes
  2.  
  3. // and
  4. CGContextSetLineDash(ADC.CGContext, 0, PCarbonDashes(@ADashes[0]), Length(ADashes));// count = length(Adashes) indeed
[
Anyway, I noticed that TCarbonDashes is declared as a dynamic array. now. So it can be that ADashes is declared wrong.
The error indicates you used a fixed length array[0..1] for ADashes instead of a dynamic array.
« Last Edit: June 17, 2019, 11:46:23 am by Thaddy »
Specialize a type, not a var.

nsl

  • New Member
  • *
  • Posts: 16
Re: Is Mac carbon broken..
« Reply #4 on: June 17, 2019, 02:38:29 pm »

GetDashes expects parameter of type TCarbonDashes where
TCarbonDashes = array of Float32;

But the parameter passed is
CarbonDashStyle: Array [0..1] of Single

Float32 is alias for Single so should be assignment compatible.

I tried compiling the trunk code with version 3.0.4 I386 compiler and Carbon with no errors.

Could this be a compiler version issue?
Lazarus 2.1 on Windows 10 / macOS Mojave

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Is Mac carbon broken..
« Reply #5 on: June 17, 2019, 05:23:14 pm »

GetDashes expects parameter of type TCarbonDashes where
TCarbonDashes = array of Float32;

But the parameter passed is
CarbonDashStyle: Array [0..1] of Single

Float32 is alias for Single so should be assignment compatible.

I tried compiling the trunk code with version 3.0.4 I386 compiler and Carbon with no errors.

Could this be a compiler version issue?

In FPC trunk, conversion from regular arrays to dynamic ones has been disabled by default. See this for more info and how to enable it : https://wiki.lazarus.freepascal.org/User_Changes_Trunk#Disabled_default_support_for_automatic_conversions_of_regular_arrays_to_dynamic_arrays

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Is Mac carbon broken..
« Reply #6 on: June 17, 2019, 07:52:49 pm »
sounds like the fix is trivial
Quote
Remedy: Either change the code so it no longer assigns regular arrays to dynamic arrays, or add {$modeswitch arraytodynarray}
I have an old app that must stay on carbon for s while yet; as it is run on old mac's.
how old macOS are? (10.5, 10.4? older?)

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Is Mac carbon broken..
« Reply #7 on: June 17, 2019, 08:39:05 pm »
On trunk fpc and Lazarus
I have tried the {$modeswitch arraytodynarray}
in project lpr, and main unit1.pas of a an empty project, done a clean rebuild of blank form and get the same error.

Where should I be placing the {$modeswitch arraytodynarray} ?

The best way to get accurate information on the forum is to post something wrong and wait for corrections.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Is Mac carbon broken..
« Reply #8 on: June 17, 2019, 09:24:03 pm »
seems like the fix is only used for parameters passing.

try this patch.
Code: Diff  [Select][+][-]
  1. Index: carbongdiobjects.pp
  2. ===================================================================
  3. --- carbongdiobjects.pp (revision 61402)
  4. +++ carbongdiobjects.pp (working copy)
  5. @@ -2022,13 +2022,13 @@
  6.   ------------------------------------------------------------------------------}
  7.  procedure TCarbonPen.Apply(ADC: TCarbonContext; UseROP2: Boolean);
  8.  
  9. -  function GetDashes(Source: TCarbonDashes): TCarbonDashes;
  10. +  function GetDashes(const Source: array of Single): TCarbonDashes;
  11.    var
  12.      i: Integer;
  13.    begin
  14. -    Result := Source;
  15. +    SetLength(Result, length(Source));
  16.      for i := Low(Result) to High(Result) do
  17. -      Result[i] := Result[i] * FWidth;
  18. +      Result[i] := Source[i] * FWidth;
  19.    end;
  20.  
  21.  var
  22.  

Oddly enough, this was the exact place I've recently rewritten Cocoa getting rid of dynamic arrays (and dynamic array reallocation) completely

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Is Mac carbon broken..
« Reply #9 on: June 17, 2019, 11:57:59 pm »
Hi

The patch is helping, I can now compile a empty form; but when targeting for carbon I am getting
Code: [Select]
Compile Project, CPU: i386, Target: /Users/josh/lazarus_trunk_cocoa/projects/project1: Success, Errors: 21
Error: ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//Cocoa.framework/Cocoa.tbd and library file /System/Library/Frameworks//Cocoa.framework/Cocoa are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//ApplicationServices.framework/Versions/A/ApplicationServices.tbd and library file /System/Library/Frameworks//ApplicationServices.framework/Versions/A/ApplicationServices are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//AppKit.framework/Versions/C/AppKit.tbd and library file /System/Library/Frameworks//AppKit.framework/Versions/C/AppKit are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//CoreGraphics.framework/Versions/A/CoreGraphics.tbd and library file /System/Library/Frameworks//CoreGraphics.framework/Versions/A/CoreGraphics are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//CoreText.framework/Versions/A/CoreText.tbd and library file /System/Library/Frameworks//CoreText.framework/Versions/A/CoreText are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//ImageIO.framework/Versions/A/ImageIO.tbd and library file /System/Library/Frameworks//ImageIO.framework/Versions/A/ImageIO are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS.tbd and library file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//CoreServices.framework/Versions/A/CoreServices.tbd and library file /System/Library/Frameworks//CoreServices.framework/Versions/A/CoreServices are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices.tbd and library file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis.tbd and library file /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation.tbd and library file /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork.tbd and library file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices are out of sync. Falling back to library file for linking.
Error: ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList are out of sync. Falling back to library file for linking.


I added a few standard controls; label; combox and tmemo.
Moving around a putting some text in I then got estack overflow error
« Last Edit: June 18, 2019, 12:27:33 am by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

nsl

  • New Member
  • *
  • Posts: 16
Re: Is Mac carbon broken..
« Reply #10 on: June 18, 2019, 12:47:46 pm »
@skalogryz
Re: line style code in Cocoa. I have made additional comments to your changes as reported in Mantis #0034744. Would you be able to review please?

@josh
I get these warnings as well but my code compiles and runs OK
Lazarus 2.1 on Windows 10 / macOS Mojave

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Is Mac carbon broken..
« Reply #11 on: June 18, 2019, 02:50:28 pm »
Re: line style code in Cocoa. I have made additional comments to your changes as reported in Mantis #0034744. Would you be able to review please?
from #34744
Quote
1) Thank you for implementing the added cosmetic pen styles.
nah. thank you for the patch.

Quote
2) The modification to the patterns for geometric pens is not implemented. I have attached powerpoint slides as evidence that better comparison is possible. These show even better agreement with Windows than my earlier patch.
ok. need to do more work (as shown on slide 6)

Quote
3) I have attached a zipped project of the test harness I used to comparing line styles.
test project is helpful indeed. mind if I publish it? (on github?)

Quote
4) There is no change to the Carbon implementation. Is this to remain legacy?
Yes. well, maybe THIS issue would trigger the change. But honestly, I don't really want to do ANY updates to carbon.
(I'd rather make cocoa run on prior version of macOS instead :))

aside question. what are you developing?
I've never seen ANY developer to prepare a powerpoint presentation as an evidence of (non)working code.

upd: please try the latest trunk. Geometric styles should now be much better.
« Last Edit: June 18, 2019, 03:50:06 pm by skalogryz »

nsl

  • New Member
  • *
  • Posts: 16
Re: Is Mac carbon broken..
« Reply #12 on: June 18, 2019, 07:46:45 pm »
Just tried revision 61411. Line styles now good. I'll close the ticket.

I have no problem if you wish to publish the test code on github.

I came across the line styles issue when transferring a small Windows scientific project using TAChart. The dotted lines did not look the same. I had recently got a MacBook and now that Lazarus is so much better on MacOS I thought I would give it a try.

My background is in scientific computing and very use to using Powerpoints to publish ideas to colleagues and managers.

Thank you for your help.
Lazarus 2.1 on Windows 10 / macOS Mojave

 

TinyPortal © 2005-2018