【发布时间】:2017-04-11 20:05:18
【问题描述】:
我在 Delphi Berlin 有一个程序,我想将它转换为 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 中它可以完美运行。我该如何克服这个问题?
【问题讨论】:
-
如果您查看源代码 (System.Classes),您会发现 BinToHex 和 HexToBin 函数仅在
$IFNDEF NEXTGEN可用,我很确定(尽管我可能是错的 -我没有过多关注 Linux 支持,因为我目前不需要它)Linux 编译器是 NEXTGEN,因此这些功能将不可用。 Windows 编译器不是 NEXTGEN,所以函数在那里可用。 -
是的,Linux 编译器是 NEXTGEN 编译器