I get this error:
[DCC Error] JwaStrSafe.pas(2277): E2010 Incompatible types: 'PSTRSAFE_LPWSTR' and 'PSTRSAFE_LPTSTR'
Below is the corresponding piece of code from JwaStrSafe.pas (from Jedi Api), I am compiling with a specific UNICODE character:
type STRSAFE_LPWSTR = PWIDECHAR; PSTRSAFE_LPWSTR = ^STRSAFE_LPWSTR; {$IFDEF UNICODE} STRSAFE_LPTSTR = STRSAFE_LPWSTR; PSTRSAFE_LPTSTR = ^STRSAFE_LPTSTR; {$ELSE} ... {$ENDIF} ... //function declaration function StringCchCopyExW( {__out_ecount(cchDest)}pszDest : STRSAFE_LPWSTR; {__in}cchDest : size_t; {__in}const pszSrc : STRSAFE_LPCWSTR; {__deref_opt_out_ecount(pcchRemaining^)}ppszDestEnd : PSTRSAFE_LPWSTR; {__out_opt}pcchRemaining : PSize_t; {__in}dwFlags : Cardinal) : HRESULT; stdcall; forward; external; ... //var passed to function ppszDestEnd : PSTRSAFE_LPTSTR; ... {$IFDEF UNICODE} result := StringCchCopyExW(pszDest, cchDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); {$ELSE} result := StringCchCopyExA(pszDest, cchDest, pszSrc, ppszDestEnd, pcchRemaining, dwFlags); {$ENDIF}
I get an error when calling StringCchCopyExW on the ppszDestEnd parameter.
Looking at the type definition, I understand that PSTRSAFE_LPTSTR is a pointer type for STRSAFE_LPTSTR, which is just an alias for STRSAFE_LPWSTR, why are PSTRSAFE_LPTSTR and PSTRSAFE_LPWSTR incompatible?
Decision
Thanks to David's explanation, I replaced
PSTRSAFE_LPTSTR = ^STRSAFE_LPTSTR;
from
PSTRSAFE_LPTSTR = PSTRSAFE_LPWSTR;
Now the code compiles without errors.
thanks
Paolo biondi
source share