xsharp.eu • byte ptr/psz conversion?
Page 1 of 1

byte ptr/psz conversion?

Posted: Thu Sep 29, 2022 8:24 pm
by ic2
I am converting WildSeek and used an earlier conversion which still worked in Vulcan. I come across a few XS0266 errors (Cannot implicitly convert type... which I don't know how to solve (as it is external code to me).

Code: Select all

ptrBlock	:= Ptr( _cast, pszBlock )
where ptrBlock ais a Byte ptr and pszBlock a psz; error is ptr to byte

Code: Select all

pPszPartBuffer	:= Ptr(_cast, MemAlloc(wPartBufferLen) )
where pPszPartBuffer is a Psz Ptr; error is psz to psz (which doesn't make sense as error message I'd say, as it looks like it's both psz.

How should I get rid of the compiler error?

Dick

byte ptr/psz conversion?

Posted: Thu Sep 29, 2022 10:22 pm
by Chris
Hi Dick,

If you enable the option "Implicit casts and conversions (/vo7)" in the Project settings/Dialect page, it should compile, I guess the vulcan project did have that enabled, too.
But I don't think there's a need for those casts in the code, you should be able to remove them (and just leave the assignments) and the code should still run fine.

.

byte ptr/psz conversion?

Posted: Fri Sep 30, 2022 9:31 am
by ic2
Hello Chris,

Indeed 3 of the 4 errors disappeared with removing all cast code, which makes it at least easier to understand.

Code: Select all

ptrDest			:= Ptr(_cast, pPszPartBuffer)
This line did not (I basically have no idea how you could cast something to a Byte Ptr) but the implicit option, indeed unchecked, solved also that one, thanks.

Dick

byte ptr/psz conversion?

Posted: Fri Sep 30, 2022 2:00 pm
by Chris
Hi Dick,

You're welcome, just keep an eye on that code (after you have also the rest compiling) at runtime, to make sure it does work correctly when executed (no runtime errors and it does what it's supposed to do), because I do not know the context in which it runs, so am not 100% certain it will be ok.