1

我在 Windows 8.1 上使用 Free Pascal 2.6.4 32 位。我想使用 TFileStream 来复制文件。

program copy;

procedure CopyFile (strFilename : string);
var
   SourceF, DestF :  TFileStream;
begin
end;
begin
   writeln('starting ');

end.

编译器无法识别 TFileStream:

fpc copy_small.pas
Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling copy_small.pas
copy_small.pas(5,33) Error: Identifier not found "TFileStream"
copy_small.pas(5,33) Error: Error in type definition
copy_small.pas(12) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
Error: C:\FPC\2.6.4\bin\i386-Win32\ppc386.exe returned an error exitcode (normal if you did not specify a source file to be compiled)

我在网上找到的使用 TFileStream 的示例代码没有“uses”子句。为了在 Free Pascal 中使用 TFileStream,是否需要在命令行中设置或包含在程序中?

4

1 回答 1

1

TFileStream住在Classes单元里,所以你的代码应该是

program copy;

// To use any 'non-system' functionality add necessary units here
uses
  Classes;

procedure CopyFile (strFilename : string);
var
   SourceF, DestF :  TFileStream;
begin
end;
begin
   writeln('starting ');

end.
于 2014-09-21T06:23:03.340 回答