Board index » delphi » Interresting bug in Delphi 4: math.pas

Interresting bug in Delphi 4: math.pas

It took me some time to find out, maybe someone had the same problem...

Try the following
1) create a unit 'math' and save it as 'math.pas' . An empty declaration
will do:
unit math;
interface
implementation
begin
end.

2 create a new project in Delphi 4 and save it to the same directory as
'math.pas'. An empty form will do.

3 Compile (make sure 'Build with runtime packages' is OFF)
..You'll get the error:
[Fatal Error] Project1.dpr(5): Unit Forms was compiled with a different
version of math.Max

--> Delphi tries to compile math.pas even if it's not part of the project!
If you do compile WITH runtime packages this error won't occur...

Interresting but time-consuming to find out (Delphi 3 didn't do this)...
Patrick

patrick.luginbu...@switzerland.org

 

Re:Interresting bug in Delphi 4: math.pas


I'm not sure this is a bug. If you go replacing the basic building
blocks of Delphi with empty units things don't work any more. This is
not very surprising to me. Try it with sysutils.pas and you get:

[Fatal Error] Project1.dpr(5): Unit Forms was compiled with a
different version of SysUtils.Exception

I presume D3 didn't do this because it didn't check for system units
in the project directory, but I'm guessing.

Scott

Quote
Patrick Luginbhl wrote in message <72rve6$l2...@news.eunet.ch>...
>It took me some time to find out, maybe someone had the same
problem...

>Try the following
>1) create a unit 'math' and save it as 'math.pas' . An empty
declaration
>will do:
>unit math;
>interface
>implementation
>begin
>end.

>2 create a new project in Delphi 4 and save it to the same directory
as
>'math.pas'. An empty form will do.

>3 Compile (make sure 'Build with runtime packages' is OFF)
>..You'll get the error:
>[Fatal Error] Project1.dpr(5): Unit Forms was compiled with a
different
>version of math.Max

>--> Delphi tries to compile math.pas even if it's not part of the
project!
>If you do compile WITH runtime packages this error won't occur...

>Interresting but time-consuming to find out (Delphi 3 didn't do
this)...
>Patrick

>patrick.luginbu...@switzerland.org

Re:Interresting bug in Delphi 4: math.pas


Quote
> I'm not sure this is a bug. If you go replacing the basic building
> blocks of Delphi with empty units things don't work any more.

It doesn't need to be empty. *any* unit-like file with the name math.pas
will do!

Quote
> not very surprising to me. Try it with sysutils.pas and you get:
> [Fatal Error] Project1.dpr(5): Unit Forms was compiled with a different

version of SysUtils.Exception

That's different in an important point: you do use sysutils in (almost)
every project, hence it is part of the project (it's put by default in the
uses clause). I do understand that this fails (the compiler is requested to
compile
all releated units in a project).

BUT: I don't have any math.pas from Delphi (just the math.dcu), and I never
made it part of the project
- hence I never asked Delphi to compile it!I would understand that Delphi
comes into troubles if I created a
new math.pas to be used in a project!
I think math.pas is used indirectly from another unit, but the behaviour of
Delphi in this case _is_ strange...

The question remains: why does Delphi try to compile an unit that's not
part of the project at all? Just because of its name... just beause...?

Patrick

patrick.luginbu...@switzerland.org

Re:Interresting bug in Delphi 4: math.pas


On Wed, 18 Nov 1998 07:17:10 +0100, "Patrick Luginbhl"

Quote
<patrick.luginbu...@switzerland.org> wrote:
>BUT: I don't have any math.pas from Delphi (just the math.dcu), and I never
>made it part of the project
>- hence I never asked Delphi to compile it!I would understand that Delphi
>comes into troubles if I created a
>new math.pas to be used in a project!
>I think math.pas is used indirectly from another unit, but the behaviour of
>Delphi in this case _is_ strange...

I don't see why you see it as strange.  Presumably one of the VCL
units uses Math, and the compiler notices that, and when it sees that
you've got a new version of Math.pas in your project directory, it
tries to compile it.

Quote
>The question remains: why does Delphi try to compile an unit that's not
>part of the project at all? Just because of its name... just beause...?

Let's suppose you found a bug in Math.pas, and wanted to fix it.  You
would take the source, fix the bug, and then put the unit in your
project directory, and it would be recompiled.  How can the compiler
tell that this isn't what you wanted to do?

Unit names are global.  You can never have two units with the same
name in a project.  When the compiler sees that some unit uses Math,
and sees that Math.pas is in the project directory, it has no choice
but to recompile it.

In D3, none of the standard units uses Math.  Presumably one of them
does in D4, or you're using a nonstandard unit that does.  You can get
some help at guessing at which unit used a particular unit by looking
at a .MAP file (turn this on in the linker options).  Except in the
case of circular uses clauses, a unit name will always appear in the
segment list *after* every unit that it uses.

Duncan Murdoch

Other Threads