fbpx

LPSTR_TEXTCALLBACK

More
2 months 1 week ago #1 by Arne Ortlinghaus
LPSTR_TEXTCALLBACK was created by Arne Ortlinghaus
When trying to compile the GUI classes furnished by Vulcan with the new compiler I get for the following line
#define LPSTR_TEXTCALLBACK PSZ(_CAST, 0xFFFFFFFF)
the error
Error XS9068 The compiler generated an automatic conversion to PSZ. This may create a memory leak in your application. Please use String2Psz() to let the compiler manage the lifetime of the PSZ or use StringAlloc() and manage the lifetime of the PSZ yourself.

I ask me how to resolve this ugly piece of code, since it is a casting of a number into a string.

Looking to the original C code I can see that already there is the same ugly code:
#define LPSTR_TEXTCALLBACKW ((LPWSTR)-1)

Arne

Please Log in or Create an account to join the conversation.

More
2 months 1 week ago #2 by Arne Ortlinghaus
Replied by Arne Ortlinghaus on topic LPSTR_TEXTCALLBACK
Oops, spying with ILSpy into the VOWin32APILibrary delivered with X# shows that it seems to need quite a lot of tricks to get that work:

public static initonly LPSTR_TEXTCALLBACK := Xs_0024PSZLiteralsTable.__0024psz__0024460 as __Psz

internal static class Xs_0024PSZLiteralsTable
internal static initonly __0024psz__0024460 := __Psz{(IntPtr)(-1)} as __Psz
internal static initonly __0024psz__0024457 := __Psz{(IntPtr)(-1)} as __Psz
internal static initonly __0024psz__0024458 := __Psz{"frames"} as __Psz
internal static initonly __0024psz__0024459 := __Psz{"ms"} as __Psz
end class

Please Log in or Create an account to join the conversation.

More
2 months 1 week ago #3 by Chris Pyrgas
Replied by Chris Pyrgas on topic LPSTR_TEXTCALLBACK
Hi Arne,

This is just a warning, I'd say just ignore it, since this is just a fake PSZ created only once for the life time of the application and will not have any impact or anything.

Or maybe better just change it to PTR(_CAST, 0xFFFFFFFF), this should have the same effect I think and no compiler warning :)

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
2 months 1 week ago #4 by Arne Ortlinghaus
Replied by Arne Ortlinghaus on topic LPSTR_TEXTCALLBACK
Hi Chris,

thank you. When adding the message XS9068 to the warnings to be ignored, the dll compiled. I hope that tomorrow I have finished compiling the most important Dlls and can make the first Runtime tests.

Currently I am asking me, what this construct (casting a number to a string) does really mean. Also looking at it many times, it seems so strange.

Arne

Please Log in or Create an account to join the conversation.

More
2 months 1 week ago #5 by Chris Pyrgas
Replied by Chris Pyrgas on topic LPSTR_TEXTCALLBACK
Hi Arne,

I think this is just a "fake" PSZ, a constant with a special meaning for the specific functionality where it is used, this is why I said using PTR instead of PSZ will most probably work fine as well, and is more readable what it does actually.

Chris

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.