我使用“文件 -> 新建单元”将我的应用程序源代码组织成Pascal编译单元。
以下单元可以成功编译...
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;
...
然而,这个代码存在编译错误,因为它无法在第6行识别“Exception”。
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);
...
如果我假设Exception
在SysUtils
中定义(我该如何判断?),那么我无法在interface
之前添加uses SysUtils
(编译器会报错,因为它期望看到interface
)。
我该如何告诉编译器Exception
在SysUtils
中定义?
uses SysUtils
行放在interface
行之后(即不要放在它之前)。 - Paul R