Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

forward declaration of procedure in delphi

How can I make a forward declaration of a procedure in Delphi and make it's implementation in other place? I want to do something like this C's code but in Delphi:

void FooBar();

void FooBar()
{
    // Do something
}
like image 884
Seatless Avatar asked May 13 '13 17:05

Seatless


People also ask

How do you forward a function declaration?

To write a forward declaration for a function, we use a function declaration statement (also called a function prototype). The function declaration consists of the function header (the function's return type, name, and parameter types), terminated with a semicolon. The function body is not included in the declaration.

What is unsatisfied forward or external declaration Delphi?

This error message appears when you have a forward or external declaration of a procedure or function, or a declaration of a method in a class or object type, and you don't define the procedure, function or method anywhere. Maybe the definition is really missing, or maybe its name is just misspelled.

What is forward declaration in Oracle?

This declaration makes that program available to be called by other programs even before the program definition. Remember that both procedures and functions have a header and a body. A forward declaration consists simply of the program header followed by a semicolon (;). This construction is called the module header.


1 Answers

You do that with the forward directive, like so:

procedure FooBar(); forward;

...
//later on

procedure FooBar()
begin
    // Do something
end;

This is only necessary if you're declaring it as an internal function. (ie. already inside the implementation section of your unit.) Anything declared as a method of a class, or in the interface section of the unit, is automatically understood to be forward-declared.

like image 65
Mason Wheeler Avatar answered Sep 19 '22 02:09

Mason Wheeler