Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread Mattias Gaertner
On Thu, 22 Feb 2018 12:48:21 +0100 (CET)
Michael Van Canneyt  wrote:

>[...]
> home:~/source/testsub> fpc a.pp  
> unit1.pas(1,9) Error: Illegal unit name: foo (expecting FOO)
> unit1.pas(7,1) Fatal: There were 1 errors compiling module, stopping
> Fatal: Compilation aborted
> 
> Where
> 
> a.pp:
> -
> uses foo in 'unit1.pas', bar in 'sub/unit1.pas';
> 
> begin
>dofoo;
>dobar;
> end.
> 
> Unit1.pp:

This does not fit: Unit1.pp and unit1.pas.


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread Mattias Gaertner
On Thu, 22 Feb 2018 17:04:25 +0100
Mattias Gaertner  wrote:

> On Thu, 22 Feb 2018 10:41:29 -0500
> wkitt...@windstream.net wrote:
> 
> > On 02/22/2018 09:49 AM, Michael Van Canneyt wrote:  
> > > On Thu, 22 Feb 2018, Mattias Gaertner wrote:
> > >> On Thu, 22 Feb 2018 12:48:21 +0100 (CET)
> > >> Michael Van Canneyt  wrote:
> > >>> First of all, normally it won't work either way, because you must use
> > >>> "unit foo;" and "unit bar;" in the files. >>
> > >> No, I can use normal units. This works here:
> > > 
> > > Strange. I get the error I showed if I try that.
> > 
> > 
> > both of you are using the same mode? delphi or whatever? neither set of 
> > sample 
> > code shows a specific mode to use...  
> 
> It works here with both -Mdelphi and -Mobjfpc
> 
> Free Pascal Compiler version 3.0.4
> 
> Compiler date  : 2017/08/05
> Compiler CPU target: x86_64

And it works with 

Free Pascal Compiler version 3.1.1

Compiler date  : 2018/01/15
Compiler CPU target: x86_64


Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread Mattias Gaertner
On Thu, 22 Feb 2018 10:41:29 -0500
wkitt...@windstream.net wrote:

> On 02/22/2018 09:49 AM, Michael Van Canneyt wrote:
> > On Thu, 22 Feb 2018, Mattias Gaertner wrote:  
> >> On Thu, 22 Feb 2018 12:48:21 +0100 (CET)
> >> Michael Van Canneyt  wrote:  
> >>> First of all, normally it won't work either way, because you must use
> >>> "unit foo;" and "unit bar;" in the files. >>  
> >> No, I can use normal units. This works here:  
> > 
> > Strange. I get the error I showed if I try that.  
> 
> 
> both of you are using the same mode? delphi or whatever? neither set of 
> sample 
> code shows a specific mode to use...

It works here with both -Mdelphi and -Mobjfpc

Free Pascal Compiler version 3.0.4

Compiler date  : 2017/08/05
Compiler CPU target: x86_64

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread wkitty42

On 02/22/2018 09:49 AM, Michael Van Canneyt wrote:

On Thu, 22 Feb 2018, Mattias Gaertner wrote:

On Thu, 22 Feb 2018 12:48:21 +0100 (CET)
Michael Van Canneyt  wrote:

First of all, normally it won't work either way, because you must use
"unit foo;" and "unit bar;" in the files. >>

No, I can use normal units. This works here:


Strange. I get the error I showed if I try that.



both of you are using the same mode? delphi or whatever? neither set of sample 
code shows a specific mode to use...



--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list unless*
   *a signed and pre-paid contract is in effect with us.*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread Michael Van Canneyt



On Thu, 22 Feb 2018, Mattias Gaertner wrote:


On Thu, 22 Feb 2018 12:48:21 +0100 (CET)
Michael Van Canneyt  wrote:


[...]
First of all, normally it won't work either way, because you must use "unit foo;" and "unit bar;" in the files. 


No, I can use normal units. This works here:


Strange. I get the error I showed if I try that.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread Mattias Gaertner
On Thu, 22 Feb 2018 12:48:21 +0100 (CET)
Michael Van Canneyt  wrote:

>[...]
> First of all, normally it won't work either way, because you must use "unit 
> foo;" and "unit bar;" in the files. 

No, I can use normal units. This works here:

---test1.pas---
uses foo in 'unit1.pas', unit1, bar in 'sub/unit1.pas';

Begin
  i:=3; // from unit1.pas
  foo.i:=foo.i+1; // from unit1.pas
  bar.j:=27; // from sub/unit1.pas
  writeln(foo.i,' ',unit1.i,' ',bar.j);
end.
---

---unit1.pas---
unit unit1;

interface

uses foo in 'sub/unit1.pas'; // unit1 uses another unit1

var i: integer;

implementation
end.
---

---sub/unit1.pas---
unit unit1;

interface

var j: integer;

implementation
end.
---

Mattias

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] uses in 'filename'

2018-02-22 Thread Michael Van Canneyt



On Thu, 22 Feb 2018, Mattias Gaertner wrote:


Hi,

FPC allows to use two different units with the same name:

uses foo in 'unit1.pas', bar in 'sub/unit1.pas';

Which might fail with linking errors.

Is this a feature or a bug?


A feature.

First of all, normally it won't work either way, because you must use "unit foo;" and 
"unit bar;" in the
files. A quick test confirms this:

home:~/source/testsub> fpc a.pp
unit1.pas(1,9) Error: Illegal unit name: foo (expecting FOO)
unit1.pas(7,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

Where

a.pp:
-
uses foo in 'unit1.pas', bar in 'sub/unit1.pas';

begin
  dofoo;
  dobar;
end.

Unit1.pp:
-

unit foo;

interface

procedure dofoo;

implementation

procedure dofoo;

begin
  writeln('foo');
end;

end.


sub/unit1.pp:
-
unit bar;

interface

procedure dobar;

implementation

procedure dobar;

begin
  writeln('bar');
end;

end.

But if you tell the compiler to ignore the unit filenames (-Un) then you get

home:~/source/testsub> fpc -Un a.pp
home:~/source/testsub> ./a 
foo

bar

And then it works perfectly.

All assembler is prefixed using the declared
unit name:
.file "unit1.pas"
# Begin asmlist al_procedures

.section .text.n_foo_$$_dofoo

etc.


Michael.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal