2017-04-11 54 views
0

我有一個德爾福柏林的程序,我想轉換爲Linux作爲控制檯應用程序。下面是我的程序:Delphi東京HexToBin Linux版

StrVal is declare as Private 

procedure DoGetSy(); 
var 
    s: String; 
    n: Integer; 
    HasSy: Boolean; 
begin 
    HasSy := False; 
    if ch = '_' then begin 
    SyBegPos := ix-1; 
    sy := StrCharSetSy; 
    GetChar(); 
    GetIdent(); 
    Ident := '_' + Ident; 
    HasSy := True; 
    end; 
    if (not HasSy) and (IBServerOptions.SQLServerVersion in [st_Firebird_25, st_Firebird_30]) then begin 
    if (ch = '0') and ((CurCh()='x') or (CurCh()='X')) then begin 
     // hex literal (integer) 
     sy := IntValSy; 
     GetChar(); 
     GetChar(); 
     StrVal := ''; 
     while CharInSet(ch, ['0'..'9','A'..'F','a'..'f']) do begin 
     StrVal := StrVal + ch; 
     GetChar(); 
     end; 
// (?) Int64 
//  IntVal := StrToInt('$' + StrVal); 
     IntVal := 0; 
     if TryStrToInt(StrVal, n) then begin 
     IntVal := n; 
     end; 
     HasSy := True; 
    end 
    else if ((UpCase(ch) = 'X') and (CurCh() = '''')) then begin 
     // hex literal (binary string) 
     GetChar(); 
     sy := StrValSy; 
     StrQuoteCh := ch; 
     StrVal := GetStr(); 
     n := Length(StrVal); 
     if (Odd(n)) then n := (n div 2) + 1 
     else n := n div 2; 
     StrVal := LowerCase(StrVal); 
     SetLength(s, n); 
     HexToBin(PChar(StrVal), PChar(s), n);// in Linux here compiler gives exception as There is no overloaded version of 'HexToBin' that can be called with these arguments 
     StrVal := s; 
     HasSy := True; 
    end; 
    end; // Firebird 2.5, 3.0 
    if not HasSy then begin 
    inherited; 
    if (sy = StrValSy) and (StrQuoteCh = '"') and 
     (IBServerOptions.SQLDialect = 3) and (StrVal <> '') then begin 
     sy := IdentSy; 
     Ident := StrVal; 
    end; 
    end; 
end; 

在Linux下它使用下面的方法:

procedure BinToHex(const Buffer: TBytes; BufOffset: Integer; 
    var Text: TBytes; TextOffset: Integer; Count: Integer); overload; 

,其中在Windows上,它完美地工作。我怎樣才能克服這一點?

+1

如果你看看源代碼(System.Classes),你會發現BinToHex和HexToBin函數只有'$ IFNDEF NEXTGEN'可用,我很確定(雖然我可能是錯的 - 我已經由於我目前不需要Linux支持,所以沒有多加註意)Linux編譯器是NEXTGEN,所以這些函數將不可用。 Windows編譯器不是NEXTGEN,所以函數在那裏可用。 –

+0

是的,Linux編譯器是一個NEXTGEN編譯器 –

+2

相關:[如何在Android的Delphi Firemonkey中使用HextoBin](http://stackoverflow.com/questions/42962063/)。 –

回答

2

您試圖調用的HexToBin()的重載版本在NEXTGEN編譯器(iOS,Android和Linux)上不存在。這些是這些編譯器上可用的唯一過載:

function HexToBin(const Text: PChar; TextOffset: Integer; 
    var Buffer: TBytes; BufOffset: Integer; Count: Integer): Integer; overload; 

function HexToBin(const Text: TBytes; TextOffset: Integer; 
    var Buffer: TBytes; BufOffset: Integer; Count: Integer): Integer; overload; 

您必須相應地調整您的代碼。

相關問題