2012-04-03 82 views
-1

C代碼如何轉換爲delphi?將C中的聲明轉換爲Delphi

static unsigned char tempbuf[128*1024]; 

由於

+0

那你試試? – 2012-04-03 00:54:27

+0

'tempbuf:byte [0..128 * 1024-1];我是否正確? – paulohr 2012-04-03 00:57:13

+1

關閉。看到我的答案。 – 2012-04-03 01:40:27

回答

4

數組本身聲明這樣在Delphi:

tempbuf: array[0..(128*1024)-1] of Byte; 

關於static部 - 這取決於其中陣列被聲明。如果在全局內存中聲明,那麼你就需要將其聲明爲在Delphi static,只是把它放在一個全球性的var部分:

unit ...; 

interface 

var 
    tempbuf: array[0..(128*1024)-1] of Byte; 

... 

implementation 

... 

end. 

或者:

unit ...; 

interface 

... 

implementation 

var 
    tempbuf: array[0..(128*1024)-1] of Byte; 

... 

end. 

根據是否該陣列需要其他單位可訪問或不可訪問。

在另一方面,如果數組是一類的成員/結構來代替,然後宣佈它作爲德爾福class var

type 
    TSomeClass = class 
    class var 
    tempbuf: array[0..(128*1024)-1] of Byte; 
    end; 
+0

完美的作品!非常感謝。 – paulohr 2012-04-03 01:44:15