delphi - Delphi 错误“E2064 左侧无法分配给”64 位
问题描述
我正在尝试将洋红色数据包捕获单元编译为 64 位。
https://www.magsys.co.uk/delphi/magmonsock.asp
当我编译时,我得到可怕的左侧无法分配给以下代码行
LongWord(bp) := LongWord(bp) + BPF_WORDALIGN(caplen + hdrlen);
这是因为LongWord
强制转换是 64 位不同的字节长度,对吗?任何人都可以帮助正确修复该行,以便它在 32 位和 64 位版本中愉快地编译吗?bp
被声明为指针。caplen
并被hdrlen
声明为整数。
BPF_WORDALIGN
功能是
function BPF_WORDALIGN(X:LongWord) : LongWord;
begin
result := (((X)+(BPF_ALIGNMENT-1))and not(BPF_ALIGNMENT-1));
end;
感谢您提供任何帮助以使其正常工作。
如果有帮助,这是故障线路的完整程序;
function pcap_read( p:PPcap;cnt:integer;CallBack:Tpcap_handler;User:pointer)
: integer;
var cc : Longword;//Counter ?
n : integer;
bp,ep: pointer; //Begin and End Point ?
//bhp : Pbpf_hdr;//pointer to BPF header struct - removed by Lars Peter
hdrlen, //Length of Header
caplen: integer;//Length of captured
begin
if NOT LoadPacketDll then
begin
p.errbuf := 'Cannot load packet.dll';
result:=-1;
exit;
end;
cc := p.cc;
n := 0;
if p.cc = 0 then
begin
// *Capture the Packets*
if PacketReceivePacket(p.adapter,p.packet,TRUE)=false then
begin
// ERROR!
p.errbuf :='Read Error: PacketRecievePacket failed';
result:=-1;
exit;
end;
cc := p.packet.ulBytesReceived;
bp := p.buffer;
end else bp := p.bp;
// Loop through each packet.
ep := ptr(longword(bp)+cc); //move end pointer
while (longword(bp) < longword(ep) ) do
begin
caplen := Pbpf_hdr(bp).bh_caplen;
hdrlen := Pbpf_hdr(bp).bh_hdrlen;
// XXX A bpf_hdr matches apcap_pkthdr.
callback(user,
Ppcap_pkthdr(bp),
ptr(longword(bp)+longword(HdrLen)));
LongWord(bp) := LongWord(bp) + BPF_WORDALIGN(caplen + hdrlen);
inc(n);
if (n >= cnt)and(cnt>0) then
begin
p.bp := bp;
p.cc := longword(ep)-longword(bp);
result := n;
exit;
end;
end;
p.cc := 0;
result:=n;
end;
解决方案
推荐阅读
- java - 如何传递特定字符串以从数据库android获取特定值
- javascript - 更新数组中的特定对象
- node.js - 我想设置更高的超时值或从我的 node.js 异步摘要请求中删除超时
- vba - 根据自己的价值隔离数据
- kubernetes - 验证数据错误:服务器找不到请求的资源;
- angular - 带有自定义离线页面的 Angular PWA
- node.js - 如何在 Jest 的自定义测试环境文件中使用 TypeScript?
- git - Git 合并获取了“错误”文件,现在重置、恢复或合并特定提交正在与它们一起工作
- java - LineStyleBuilder 和类似的无法解析 setColor() 和其他函数
- reactjs - 是否可以从 Jest 禁用特定的 React 警告(使用 Create React App)