byte ptr/psz conversion?

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

byte ptr/psz conversion?

Post 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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

byte ptr/psz conversion?

Post 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.

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

byte ptr/psz conversion?

Post 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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

byte ptr/psz conversion?

Post 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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply