I organise my app's source code into Pascal compilation Units using File -> New Unit
The following Unit compiles OK ...
unit CryptoUnit;
{$mode objfpc}{$H+}
interface
function Encrypt(key, plaintext:string):string;
function Decrypt(key, ciphertext:string):string;
implementation
uses
Classes, SysUtils, Blowfish;
function Encrypt(key, plaintext:string):string;
...
However this one has compilation errors as it can't identify "Exception" at line 6 ...
unit ExceptionUnit;
{$mode objfpc}{$H+}
interface
procedure DumpExceptionCallStack(E: Exception); // <--- problem
implementation
uses
Classes, SysUtils, FileUtil;
{ See http://wiki.freepascal.org/Logging_exceptions }
procedure DumpExceptionCallStack(E: Exception);
...
If I assume that Exception
is defined in SysUtils
(how can I tell?) I can't put uses SysUtils
before interface
(the compiler complains it was expecting interface
)
How do I tell the compiler that Exception
is defined in SysUtils
?
Other units that are used used by your unit are to be referenced after the interface keyword, but before other statements in the interface section.
Your example should work in the following form:
unit ExceptionUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil;
procedure DumpExceptionCallStack(E: Exception);
implementation
{ See http://wiki.freepascal.org/Logging_exceptions }
procedure DumpExceptionCallStack(E: Exception);
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