2012-04-03 85 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