Recent

Author Topic: [SOLVED] Code does not compile on macOS  (Read 2653 times)

oh_ha

  • New member
  • *
  • Posts: 8
[SOLVED] Code does not compile on macOS
« on: June 06, 2021, 01:22:18 pm »
Hello,

I have a unit that "A" defines a class "TDirSizeForm" and a standalone procedure "CreateNewDirSizeForm" in its "interface" section.

I have a second unit "B" that "uses" the unit "A" and calls the standalone procedure "CreateNewDirSizeForm" in a method of a class defined in unit "B". This code compiles without errors or warnings on Windows, but fails to compile on MacOS (error "Identifier not found"). The strange thing is that I can create an instance of the class "TDirSizeForm" defined in unit "A" without a problem in the same method of unit "B" in which the call to the procedure "CreateNewDirSizeForm" causes the compiler error.

Any idea why I cannot compile the code on MacOS?

The environment is Lazarus 2.0.10 both on Windows (8.1) and MacOS Catalina. I am using "{$mode objfpc}" in both units.

Thanks for your help, Olaf

[Edited title to add SOLVED]
« Last Edit: June 08, 2021, 02:57:38 am by trev »

Soner

  • Sr. Member
  • ****
  • Posts: 252
Re: Code does not compile on MacOS
« Reply #1 on: June 06, 2021, 03:36:28 pm »
Maybe lowercase or capital letters issue, Windows ist capital insensitive for file names but Macos and unix not.
Write all your unit file names in lowercase letters, also in pascal files like this.

b.pas
Code: Pascal  [Select][+][-]
  1. unit b;
  2. ...
  3. end.
  4.  

a.pas
Code: Pascal  [Select][+][-]
  1. unit a;
  2. uses b;
  3.  
  4. ...
  5. end.
  6.  

Soner

  • Sr. Member
  • ****
  • Posts: 252
Re: Code does not compile on MacOS
« Reply #2 on: June 06, 2021, 03:42:03 pm »
Also your volume name looks strange.
/Volumes/$d/Artikel/...

Maybe fpc has problems with this $d part.

I used symbolic links on linux and macos as I developed crossplatform to avoid such problems. Look for 'ln -s' command.

oh_ha

  • New member
  • *
  • Posts: 8
Re: Code does not compile on MacOS
« Reply #3 on: June 06, 2021, 06:55:06 pm »
Renaming all file names and the internal "unit" names did the job: the project now successfully compiles on MacOS  -- thanks for the suggestion.

It is just strange that the compiler did resolve the class name, but not the procedure name as they are both declared in the same file.

The path / volume name is due to the fact that the project resides on a Windows PC. If I have any more problems with file names, I'll look into using symbolic links.

Thanks a lot for the speedy replies!

VTwin

  • Hero Member
  • *****
  • Posts: 1052
  • Former Turbo Pascal 3 user
Re: Code does not compile on MacOS
« Reply #4 on: June 07, 2021, 11:27:26 pm »
I'm not sure what the issue was. However, unit file names should (generally) be lower case, but can be mixed case in unit names and uses clauses. That should make Windows, Mac, and Linux happy.
« Last Edit: June 07, 2021, 11:30:05 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.0
macOS 10.13.6: Lazarus 2.0.12 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.12 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.12 (64 bit on VBox)

 

TinyPortal © 2005-2018