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
}
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With