Home > Back-end >  C structure pointer to Delphi, are you free to help thank you
C structure pointer to Delphi, are you free to help thank you

Time:09-25

 
Typedef struct _EXT_FRAME_HEAD
{
Unsigned long nStartFlag;//extended frame head start identifier
Unsigned short nVer;//version
Unsigned short nLength;//extension length of frame head
EXT_FRAME_TYPE szFrameInfo;
Unsigned long nTimestamp;//in milliseconds timestamp
Unsigned long nEndFlag;//extended frame head start identifier

Bool CheckExtFlag ()
{
Return (HH_EXT_HEAD_FLAG==nStartFlag & amp; & HH_EXT_TAIL_FLAG==nEndFlag)? true:false;
}
} EXT_FRAME_HEAD;







Typedef struct _HV_FRAME_HEAD
{
Unsigned short zeroFlag;//0
Unsigned char oneFlag;//1
Unsigned char streamFlag;//data frame tagging FRAME_FLAG_VP FRAME_FLAG_VI, FRAME_FLAG_A

Unsigned long nByteNum;//data frame size
Unsigned long nTimestamp;//timestamp
} HV_FRAME_HEAD;





The above two structure
Turn the following sentences to Delphi, how do STH over and over again for a long time the compiler are not

 
EXT_FRAME_HEAD * pExtFrameHead=(EXT_FRAME_HEAD *) (pFrameHead + sizeof (char *) (HV_FRAME_HEAD));


This sentence meaning should be defined a EXT_FRAME_HEAD type of pointer variable, then the assignment, but how to turn in Delphi?


 
Type
EXT_FRAME_HEAD=record
NStartFlag: LongInt;//extended frame head start identifier
NVer: Word;//version
NLength: Word;//extension length of frame head
SzFrameInfo: EXT_FRAME_TYPE;
NTimestamp: LongInt;//in milliseconds timestamp
NEndFlag: LongInt;//extended frame head start identifier

//here can't translation, but has nothing to do with this, but know how to turn predecessors to give directions, thank you for
//public bool CheckExtFlag ()
//{
//return (HH_EXT_HEAD_FLAG==nStartFlag & amp; & HH_EXT_TAIL_FLAG==nEndFlag)? true:false;
//}
end;
PEXT_FRAME_HEAD=^ EXT_FRAME_HEAD;

Type
HV_FRAME_HEAD=record
ZeroFlag: Word;//0
OneFlag: Byte;//1
StreamFlag: Byte;//data frame tagging FRAME_FLAG_VP FRAME_FLAG_VI, FRAME_FLAG_A
NByteNum: LongInt;//data frame size
NTimestamp: LongInt;//timestamp
end;
PHV_FRAME_HEAD=^ HV_FRAME_HEAD;



 
Var
PFrameHead: pHV_FRAME_HEAD;
PExtFrameHead: pEXT_FRAME_HEAD;

And then...

CodePudding user response:

Structure transformed to detect bytes occupied agree with c + +, and then run the specific content.

CodePudding user response:

Structure is defined in the packed record forward to its members on tight.

CodePudding user response:

Bool CheckExtFlag ()
{
Return (HH_EXT_HEAD_FLAG==nStartFlag & amp; & HH_EXT_TAIL_FLAG==nEndFlag)? true:false;
}

The function CheckExtFlag () : a Boolean;
The begin
Result:=(HH_EXT_HEAD_FLAG=(nStartFlag and HH_EXT_TAIL_FLAG=nEndFlag));
end;

CodePudding user response:

The
reference 3 floor linuxpingwangping response:
bool CheckExtFlag ()
{
Return (HH_EXT_HEAD_FLAG==nStartFlag & amp; & HH_EXT_TAIL_FLAG==nEndFlag)? true:false;
}

The function CheckExtFlag () : a Boolean;
The begin
Result:=(HH_EXT_HEAD_FLAG=(nStartFlag and HH_EXT_TAIL_FLAG=nEndFlag));
end;
it's defined in c + + structure inside, like you wrote in the structure, haven't compile, Delphi error is given

CodePudding user response:

 
Var
PFrameHead: pHV_FRAME_HEAD;
PExtFrameHead: pEXT_FRAME_HEAD;

 pExtFrameHead:=@ (pFrameHead ^); 

So write can compile, but obviously with c + + statements are much better

CodePudding user response:

 pExtFrameHead:=pEXT_FRAME_HEAD (LongWord (pFrameHead) + SizeOf (HV_FRAME_HEAD)); 

Into this, is that ok? Did, compilation can pass, but the actual effect, can't judge now

CodePudding user response:

Type
EXT_FRAME_HEAD=record
NStartFlag: LongInt;//extended frame head start identifier
NVer: Word;//version
NLength: Word;//extension length of frame head
SzFrameInfo: EXT_FRAME_TYPE;
NTimestamp: LongInt;//in milliseconds timestamp
NEndFlag: LongInt;//extended frame head start identifier
The function CheckExtFlag: Boolean;
end;

The function EXT_FRAME_HEAD. CheckExtFlag: Boolean;
The begin
Result:=(HH_EXT_HEAD_FLAG=nStartFlag) and (HH_EXT_TAIL_FLAG=nEndFlag);
end;

CodePudding user response:

EXT_FRAME_HEAD * pExtFrameHead=(EXT_FRAME_HEAD *) (pFrameHead + sizeof (char *) (HV_FRAME_HEAD));

Var
PExtFrameHead: ^ EXT_FRAME_HEAD;

PExtFrameHead:=pointer (NativeInt (pFrameHead) + sizeof (HV_FRAME_HEAD));

CodePudding user response:

reference 4 floor qq_32221623 response:
Quote: reference linuxpingwangping reply: 3/f

Bool CheckExtFlag ()
{
Return (HH_EXT_HEAD_FLAG==nStartFlag & amp; & HH_EXT_TAIL_FLAG==nEndFlag)? true:false;
}

The function CheckExtFlag () : a Boolean;
The begin
Result:=(HH_EXT_HEAD_FLAG=(nStartFlag and HH_EXT_TAIL_FLAG=nEndFlag));
end;
it's defined in c + + structure inside, like you wrote in the structure, haven't compile, Delphi was given error message


Delphi also can be put in structure function!!!!!!!!!!!!!!!!!!!!!!!!!!!!

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related