Home > Back-end >  This Incompatible types: 'PAnsiChar' and 'PWideChar compiler error. What should I do?
This Incompatible types: 'PAnsiChar' and 'PWideChar compiler error. What should I do?

Time:10-30

With Delphi XE compile the old version of the VCL, always appear the compiler error, excuse me, how to solve? Thank you very much!

CodePudding user response:


Used XE, possible only Settings like vs the character type can make a bad conversion

CodePudding user response:

Mainly, caused by the use of PChar Dephi7 PChar mean PAnsiChar, by D2010, default refers to PWideChar
Therefore, you need to change the content for PAnsiChar PChar related.

CodePudding user response:

Agree with upstairs
Pchar into PAnsiChar
I now use the 2010 is in the same situation before

CodePudding user response:

Find a lot of control error even changed, XE still is not working

CodePudding user response:

I D7 code to D2010 above it's not a big problem, the string problem is like this

CodePudding user response:

PAnsiChar...

CodePudding user response:

reference 4 floor georgepcb response:
find many control error even changed, XE or bad with
this turn XE thing ah?

CodePudding user response:

Pay attention to keep an eye on ~
Take cough up ~ ~ thank you..

CodePudding user response:

Or go back to 2007

CodePudding user response:

Return true not xe

CodePudding user response:

Type mismatch

CodePudding user response:

refer to the second floor response:
mainly, caused by the use of PChar Dephi7 PChar mean PAnsiChar, by D2010, default refers to PWideChar
Therefore, you need to change the content for PAnsiChar PChar related.

Thanks for sharing, I also in research and study the DELPHI XE in

CodePudding user response:

This is the code under the D7 completely normal:

Var tem: DWORD;
The begin
Tem:=htonl (ntohl (inet_addr (Pchar (edtPing1. Text))));
ShowMessage (IntToStr (htonl (ntohl (inet_addr (Pchar (edtPing1. Text))))));
ShowMessage (inet_ntoa (in_addr (tem)));

end;

This is a test of under 2010, but the result is not the same, edt1. The text value of the IP address
Var tem: DWORD;
The begin
Tem:=htonl (ntohl (inet_addr (PAnsiChar (edt1. Text))));
ShowMessage (IntToStr (htonl (ntohl (inet_addr (PAnsiChar (edt1. Text))))));
ShowMessage (inet_ntoa (in_addr (tem)));
end;

All turn native String String types PAnsiChar need after AnsiString transition
Tem:=htonl (ntohl (inet_addr (PAnsiChar (AnsiString (edt1. Text)))));
You can try this one, I in D2010 solve the prompt,

CodePudding user response:

Call API function gethostname Error: [DCC Error] uVIMPublicFun. Pas (449) : E2010 Incompatible types: 'Array' and 'PAnsiChar'
Var
The hostName: an array of char [0.. 255];
The begin
Gethostname (hostName, sizeof (hostName));
end;
Causes: D2009 WideChar Char as wide characters, and gethostname the first parameter is the PAnsiChar,
Solution: change the hostName of the statement to array [0.. 255] of AnsiChar; Can,

CodePudding user response:

refer to the second floor SmallHand response:
mainly, caused by the use of PChar Dephi7 PChar mean PAnsiChar, by D2010, default refers to PWideChar
Therefore, you need to change the content for PAnsiChar PChar related.

The default unicode d2009 start
  • Related