小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Lazarus中objfpc編譯模式與delphi編譯模式的不同

 quasiceo 2012-11-30

Lazarus中objfpc編譯模式與delphi編譯模式的不同

(2011-03-28 23:33:22)

今天碰到了Lazarus編譯模式的問題,以前一直認為Lazarus和delphi語法之類的都是一樣的, 今天在事實面前證明,不一樣!

編譯模式的聲明是在文件開頭,unit 下面

{$mode delphi }  或者 {$mode objfpc }

 

Lazarus官網(wǎng)說明:

This mode is selected by the $MODE DELPHI switch. It tries to emulate, as closely as possible, the behavior of Delphi 4 or higher. On the command line, this mode is selected by the -Mdelpih switch.//http://www./blog 

  1. You cannot use the address operator to assign procedural variables.
  2. A forward declaration does not have to be repeated exactly the same by the implementation of a function/procedure. In particular, you can omit the parameters when implementing the function or procedure.
  3. Ansistrings are default, this means that $MODE DELPHI implies an implicit {$H ON}.
  4. Overloading of functions is not allowed. //http://www./blog 
  5. Nested comments are not allowed.
  6. The Objpas unit is loaded right after the system unit. One of the consequences of this is that the type Integer is redefined as Longint.
  7. Parameters in class methods can have the same names as class properties (although it is bad programming practice).//http://www./blog 

This mode is selected by the $MODE OBJFPC switch. On the command line, this mode is selected by the -Mobjfpc switch.

  1. You must use the address operator to assign procedural variables.
  2. A forward declaration must be repeated exactly the same by the implementation of a function/procedure. In particular, you cannot omit the parameters when implementing the function or procedure, and the calling convention must be repeated as well.
  3. Overloading of functions is allowed.
  4. Nested comments are allowed.
  5. The Objpas unit is loaded right after the system unit. One of the consequences of this is that the type Integer is redefined as Longint.
  6. You can use the cvar type.
  7. PChars are converted to strings automatically.
  8. Parameters in class methods cannot have the same names as class properties.
  9. Strings are shortstrings by default. You can use the -Sh command line switch or the {$H+} switch to change this.

Minun幫忙的解釋:

//http://www./blog  

D.3 Delphi mode

1、你不能在函數(shù)指針或者運算符上使用地址符號
2、事先的申明可以省略參數(shù)
3、AnsiString是默認的,
4、同名函數(shù)是不允許的
5、備注嵌套是不允許的
6、objpas加載在system之后,明顯的區(qū)別在于integer是longint
7、類方法的參數(shù)可以與類屬性同名

D.4 OBJFPC mode

1、你必須在函數(shù)指針或者運算符上加上地址符號
2、事先的生命必須完全和后面的實現(xiàn)相符合,相反,你可以在實現(xiàn)中省略參數(shù)
3、同名函數(shù)是允許的//http://www./blog 
4、備注嵌套是允許的//http://www./blog 
5、objpas加載在system之后,(和delphi一樣)
6、你可以使用cvar類型
7、PChars被自動當作strings處理
8、類方法的參數(shù)不能與類屬性同名
9、String默認是ShortString,

一個例子:

記錄類型

ta=record
    a:integer;
  end ;
  Pta=^ta;     

=====================

 

 

第一種寫法:

var
  s:Pta;
begin
   s:=new(pta);
   s.a:=5;
end;       

 

第二種寫法:

var
  s:Pta;
begin
   s:=new(pta);
   s^.a:=5;
end;    

//http://www./blog   

第一種第二種寫法在Delphi模式下都能通過,而在objfpc下只能通過第二種。

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多