Draft note: missing identifiers are not missing downloads

Go down

Draft note: missing identifiers are not missing downloads

· #1

I would like to add a short troubleshooting note. My first IntToStr call produced this message excerpt:

text
Error: Identifier not found "IntToStr"

I searched for something to install. Adding SysUtils to the unit's uses clause fixed it. Can someone check that explanation before I turn one mistake into permanent documentation?

Re: Draft note: missing identifiers are not missing downloads

· #2

Finding a declaration

Your explanation is right for that error in this case. IntToStr is declared in SysUtils.

  1. Check the identifier's spelling.
  2. Find its declaration in the documentation or source.
  3. Add the declaring unit to the uses clause of the source file that needs the identifier.
  4. Put that dependency in implementation if only implementation code needs it. Public declarations that use its types need it in interface.

For example, this complete unit exposes a string result while keeping the conversion dependency private:

pascal
unit CountText;
{$mode objfpc}{$H+}
interface

function FormatCount(Value: Integer): string;

implementation
uses
  SysUtils;

function FormatCount(Value: Integer): string;
begin
  Result := IntToStr(Value);
end;

end.

Adding a unit to the project file does not make its identifiers visible throughout every other unit. Each source file needs the appropriate uses entry.

Read the error message. Then read it again.

Re: Draft note: missing identifiers are not missing downloads

· #3

i added both of my units to each other so neither would be lonely

text
Fatal: Circular unit reference between Orders and Reports

Re: Draft note: missing identifiers are not missing downloads

· #4

You have a cycle through their interface dependencies. If Reports needs Orders only inside method bodies, move that uses Orders entry to Reports' implementation section.

If both interfaces really require each other's types, moving an entry without changing those declarations will not fix it. Extract the shared types into a third unit that both can use without a cycle. A forward class declaration in one unit does not declare a class belonging to another unit.

The unit dependency reference covers both legal implementation dependencies and illegal interface cycles.

Re: Draft note: missing identifiers are not missing downloads

· #5

so neither would be lonely

I had three units arranged that way once. The dependency diagram looked like the route I took while searching for the person who designed it.

I had designed it.

Pete · thirty years of begin and end "It compiled on my machine."

Re: Draft note: missing identifiers are not missing downloads

· #6

I added the distinction between an unknown identifier and a missing unit. I also added the circular-reference case, with the warning that moving a dependency only works if the public declarations no longer need it there.

The note now has fewer installation instructions. Specifically, none.

Re: Draft note: missing identifiers are not missing downloads

· #7

Approved, including the absence of a download button.

Forum rules 1 to 10 apply. Yes, to you.

Go up

Sign in to reply