Constifier

B

Bonj

It's not made clear if this is only for pointers, or any type of parameter.
But what if I, say, pass the value in a textbox to a function with
parameters that aren't declared __opt?

Also, what syntactically is there to distinguish between "not using __opt"
and "not using this feature at all" - is there a compiler switch?
 
J

Jochen Kalmbach [MVP]

Hi Bonj!
It's not made clear if this is only for pointers, or any type of parameter.
But what if I, say, pass the value in a textbox to a function with
parameters that aren't declared __opt?

For many, many examples you can take a look at the actual platform SDK:
http://www.microsoft.com/downloads/...75-1FC4-49E5-BC66-9DA2B03D9B92&displaylang=en

The most annoations are only "buffer annotations". There are also some
"advanced annotations" (like callbacks, "caller must check return
value", ...)

Please really take a look at:
http://msdn.microsoft.com/library/en-us/winprog/winprog/header_annotations.asp

Also, what syntactically is there to distinguish between "not using __opt"
and "not using this feature at all" - is there a compiler switch?

If no SAL is available, then no check will be done...

But to eanble the checks you need to use the compiler-switch "/analyze"
(VC2005)

See:
http://winfx.msdn.microsoft.com/lib...html/81da536a-e030-4bd4-be18-383927597d08.asp

By the way: This tool (so call "prefast")is available at least one year
via DDK:
http://www.microsoft.com/whdc/devtools/tools/PREfast.mspx

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
B

Bonj

I've discovered another problem with using this, which is such a ballache
you probably wouldn't want to do it unless you got round this problem.
Namely, that it may make a method in a base class const, but not a method
that's overriden in a derived class. Hence, on an instance of a derived
class calling the function through pointer to base will call the base
class's function, giving a run-time bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top