簡體   English   中英

如何消除TFileStream上的Free Pascal“無法識別”編譯錯誤?

[英]How to eliminate Free Pascal 'not recognized' compile error on TFileStream?

我在Windows 8.1上使用32位Free Pascal 2.6.4。 我想使用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,是否需要在命令行上設置某些內容或將其包含在程序中?

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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM