Questions tagged [microsoft-sal]

Microsoft's SAL is an inline, source level API annotation language, commonly used to document WinAPI and various Microsoft projects.

Microsoft's source-code annotation language or SAL provides an inline method to document source level API functions via the use of macro's, provided by the sal.h header.

These macro's are used to decorate function arguments and return types, providing an indication of various properties, such as optionality, null-termination or buffer size. The following is an example of the SAL annotations in use (taken from MSDN):

void MyPaintingFunction(
    __in HWND hwndControl,      // An initialized read-only parameter.
    __in_opt HDC hdcOptional,   // An initialized read-only parameter
                                //  that might be NULL.
    __inout IPropertyStore *ppsStore  // An initialized parameter that
                                // may be freeely used and modified.
);

As of Visual Studio 2008, the macro's are now standardized to use a capital.

8 questions
12
votes
2 answers

Meaning of __in , __out, __in_opt

What is the meaning of these keywords used before variables in a function parameters? __in __out __in_opt
Zcube
  • 133
  • 1
  • 1
  • 7
9
votes
1 answer

What is the purpose of SAL (Source Annotation Language) and what is the difference between SAL 1 and 2?

As asked in the title: What is the purpose of SAL (Source Annotation Language) and what is the difference between SAL 1 and SAL 2? I understand the basics of the usage, and that is serves to highlight the purpose of each of the variables passed to…
Thomas Russell
  • 5,870
  • 4
  • 33
  • 68
7
votes
1 answer

what is the difference between __deref_out_opt and __deref_opt_out?

What is the difference between the following SAL annotations? void foo(__deref_out_opt PSTR* bar); void foo(__deref_opt_out PSTR* bar);
John
  • 5,561
  • 1
  • 23
  • 39
4
votes
3 answers

Microsoft's Source Annotation Language (SAL) -- any way to take advantage of it?

Is there any way to take advantage of Microsoft's SAL, e.g. through a C parser that preserves this information? Or is it made by Microsoft, for Microsoft's internal use only? It would be immensely useful for a lot of tasks, such as creating C…
user541686
  • 205,094
  • 128
  • 528
  • 886
2
votes
3 answers

SQL Subquery Join and Sum

I have Table 1 & 2 with common Column name ID in both. Table 1 has duplicate entries of rows which I was able to trim using: SELECT DISTINCT Table 2 has duplicate numeric entries(dollarspent) for ID's which I needed and was able to sum up: Table 1…
ryan199004
  • 23
  • 1
  • 3
1
vote
1 answer

How to cause SAL compiler warnings in my own code using Visual C++ without running static code analysis

If I create a new console project in VS 2019 and add my own annotated implementation of printf and call both real printf and my version: // SALTest.cpp : This file contains the 'main' function. Program execution begins and ends there. // …
Angus Graham
  • 133
  • 6
0
votes
1 answer

Microsoft's SAL Deref=1 property in relation to an "int" parameter?

I've come round to the idea that Microsoft's SAL (Source Annotation Language) is a good thing, and have studied the language and the meaning of annotation properties. I have a general question about the use of SAL's "Deref" property in connection…
Moshe Rubin
  • 1,944
  • 1
  • 17
  • 37
0
votes
1 answer

Microsoft SAL annotation -optional parameter

In winbase.h, DeviceIoControl function is defined like this. BOOL WINAPI DeviceIoControl( __in HANDLE hDevice, __in DWORD dwIoControlCode, __in_bcount_opt(nInBufferSize) LPVOID lpInBuffer, __in DWORD…
Benjamin
  • 10,085
  • 19
  • 80
  • 130