free pascal dialect

Free pascal 本身支持多种dialect方言(或者叫mode), 支持 objfpc/delphi/delphiunicode, 还有 tp/iso 等不常用的方言.

在一个项目中,  dialect 是 per unit 设定的.

不同方言支持的语法有些许区别, 主要不同体现在:  string类型具体实现形式不同, 泛型语法不同, 函数指针语法等.

官方文档:

$mode指令: https://www.freepascal.org/docs-html/prog/progap4.html#progse62.html

$H指令: https://www.freepascal.org/docs-html/prog/progsu25.html

$MODESWITCH 指令:  https://www.freepascal.org/docs-html/prog/progsu106.html

各种string的说明:  https://wiki.freepascal.org/FPC_Unicode_support#RTL_todos

需要说明的是, {$mode objfpc}{$H+}  下, string 其实为 AnsiString , Lazarus 项目缺省模式 , 但如果在开启 {$MODESWITCH UNICODESTRINGS} , string 将变为UnicodeString.

下面Free pascal 程序不能运行, 但可以通过报错信息测试, 在不同mode下string类型等价于哪种具体实现类型.

program Project1;
//{$mode objfpc}{$H+}      //string 其实为 AnsiString , Lazarus 项目缺省模式
//{$mode objfpc }          //string 其实为 ShortString
//{$mode DELPHI }          //string 其实为 AnsiString
//{$mode DELPHIUNICODE }   //string 其实为 UnicodeString

//$mode指令: https://www.freepascal.org/docs-html/prog/progap4.html#progse62.html
//$H指令: https://www.freepascal.org/docs-html/prog/progsu25.html
uses SysUtils, classes;
var
  msg:string ;
  AList:TList ;
begin
  AList:=TList.create() ;
  Alist.Add(msg);
end.
           

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值