【发布时间】:2013-08-23 16:52:40
【问题描述】:
我使用 File -> New Unit 将我的应用程序的源代码组织到 Pascal 编译单元中
下面的单元编译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;
...
但是这个有编译错误,因为它无法在第 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);
...
如果我假设Exception 是在SysUtils 中定义的(我怎么知道?)我不能把uses SysUtils 放在interface 之前(编译器抱怨它期待interface)
如何告诉编译器Exception 是在SysUtils 中定义的?
【问题讨论】:
-
我认为您需要将
uses SysUtils行紧跟在interface行之后(即不在它之前)。