From: RB on
I have a question about something I never learned. In the below code exactly
what are the " __out" and the "__in" ? I have seen these before but never had
need to learn what they do. I can understand what they say to me, but what
do they say to the compiler or more specifically does the compiler do in reaction
to them ?
HRESULT StringCchPrintf(__out LPTSTR pszDest, __in size_t cchDest, __in LPCTSTR pszFormat, __in ...);


From: Doug Harrison [MVP] on
On Wed, 28 Apr 2010 21:33:23 -0400, "RB" <NoMail(a)NoSpam> wrote:

>I have a question about something I never learned. In the below code exactly
>what are the " __out" and the "__in" ? I have seen these before but never had
>need to learn what they do. I can understand what they say to me, but what
>do they say to the compiler or more specifically does the compiler do in reaction
>to them ?
>HRESULT StringCchPrintf(__out LPTSTR pszDest, __in size_t cchDest, __in LPCTSTR pszFormat, __in ...);

They are VC++ markup to convey additional semantic information to the
compiler about how the parameters are used, and they are activated by the
/analyze compiler option. For more, see:

http://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx

Unfortunately, in this case, they neglected to require people to check the
return value, which could have been accomplished with __checkReturn. There
is a lot more on this and related features in MSDN, but unfortunately, it
like everything else in this iteration of MSDN is not particularly easy to
discover. You should also look here:

http://msdn.microsoft.com/en-us/library/ms182025.aspx

This analysis stuff is a truly great feature of the compiler, as it helps
give some teeth to documentation, and it can detect some errors at
compile-time that otherwise could only have been detected at run-time.

--
Doug Harrison
Visual C++ MVP
From: Giovanni Dicanio on
"RB" <NoMail(a)NoSpam> ha scritto nel messaggio
news:uB2n2vz5KHA.6052(a)TK2MSFTNGP02.phx.gbl...

> I have a question about something I never learned. In the below code
> exactly
> what are the " __out" and the "__in" ?

You may find the following blog post useful:

"A Brief Introduction to the Standard Annotation Language (SAL)"
http://blogs.msdn.com/michael_howard/archive/2006/05/19/602077.aspx

Giovanni



From: RB on
Wow this is some really cool stuff. (you guys are probably laughing
thinking where in the heck I have been the last half a decade).
But I just never really embraced this stuff since my older version
of VS does not have any of these macros.
Thanks for the info.


From: RB on
Wow this is some really cool stuff. (you guys are probably laughing
thinking where in the heck I have been the last half a decade).
But I just never really embraced this stuff since my older version
of VS does not have any of these macros.
Thanks for the info.