xsharp.eu • XS0219 and OUT parameters
Page 1 of 1

XS0219 and OUT parameters

Posted: Sat Feb 03, 2024 9:09 pm
by baramuse
Hi,

Is there a way to tell the compiler not to warn us with a XS0219: The variable 'nLen' is assigned but its value is never used when the variable is actually used in a function requiring an OUT parameter ?
enven if we don't use the variable, we still need it ie:

Code: Select all

WTSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientAddress, OUT pBuffer, OUT nLen )
Not a big deal but we're hunting all the warnings :)

Re: XS0219 and OUT parameters

Posted: Sat Feb 03, 2024 9:15 pm
by wriedmann
Hi Basile,
you can disable every warning you like in the compiler options.
But you can disable it also in every place of your source where you like setting a pragma:
https://www.xsharp.eu/help/pp-pragma-warnings.html
Wolfgang

Re: XS0219 and OUT parameters

Posted: Sun Feb 04, 2024 7:27 am
by robert
Basile,

If you're not using the variable, then you can also pass what's called the 'discard variable' which is just a single underscore.
If you prefix the name with the VAR keyword then the variable gets automatically declared with the right type. That looks like this:

Code: Select all

TSQuerySessionInformation( WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientAddress, OUT pBuffer, OUT VAR _ )
Robert