2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

FreePascalがDelphiと違うところ

Last updated at Posted at 2022-01-07

FreePascal(FPC)には、Delphi互換モードがあるので便利。

拙作の、テキスト音楽「サクラ」は、Delphi7に加えて、FPCでもコンパイルできるようになっている。

それで、日本語プログラミング言語「なでしこv1」もFPCでコンパイルできるようにしようと思っているのだが、なかなか難しい。

試している中で分かったことを以下にメモする。

コンパイルコマンド

以下のように、-Mdelphiを指定して、fpcコマンドを実行する。すると、Delphi互換モードになる。

$ fpc -Mdelphi -g -gv -dFPC -vewh ファイル名.dpr

SysUtils.LeadBytes問題

SJISの1文字目をSysUtils.LeadBytesで判定したのだが、これがうまく設定されない。そのため、以下のようなSJISLeadBytesを定義して、SJISの1文字目を判定する。そもそも、SJIS使わないようにすれば良いのだが、Delphi7で書いた多くのプログラムはSJISである。

sjis.pas
type
  TChars = set of AnsiChar;
const SJISLeadBytes: TChars = [#$81..#$9F,#$E0..#$FC];

2024/03/09 --- 上記値が間違っていたので修正。

ZeroMemory がないので FillByte を使う

パラメータが若干違うけど、単純に置換可能。

ただし、第一引数には、ポインタではなく、ポインタが指す値を指定する必要があり、利用には注意。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?