XS0219 and OUT parameters

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
baramuse
Posts: 85
Joined: Tue Nov 29, 2022 8:31 am
Location: France

XS0219 and OUT parameters

Post 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 :)
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: XS0219 and OUT parameters

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: XS0219 and OUT parameters

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply