draft changes · Pawwz85/cpp-docs@65ea766 · GitHub
Skip to content

Commit 65ea766

Browse files
committed
draft changes
1 parent d2374d5 commit 65ea766

15 files changed

Lines changed: 141 additions & 18 deletions

docs/build/building-on-the-command-line.md

Lines changed: 1 addition & 1 deletion

docs/build/reference/zf.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The **/Zf** option enables compiler support for faster generation of PDB files w
1919

2020
Because the **/Zf** option only applies to PDB generation, it requires the [/Zi](z7-zi-zi-debug-information-format.md) or [/ZI](z7-zi-zi-debug-information-format.md) option.
2121

22-
The **/Zf** option is available beginning in Visual Studio 2017 version 15.1, where it is off by default. Starting in Visual Studio 2017 version 15.7, this option is on by default when the **/Zi** or **/ZI** option is enabled.
22+
The **/Zf** option is available beginning in Visual Studio 2017 version 15.1, where it is off by default. Starting in Visual Studio 2017 version 15.7, this option is on by default when the **/Zi** or **/ZI** option is enabled. To explicitly disable this option, use **/Zf-**.
2323

2424
### To set this compiler option in the Visual Studio development environment
2525

docs/c-runtime-library/reference/calloc-dbg.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ For information about how memory blocks are allocated, initialized, and managed
6868

6969
## Requirements
7070

71-
| Routine | Required header |
72-
|---|---|
73-
| **`_calloc_dbg`** | \<crtdbg.h> |
71+
| Routine | Required header | Required library |
72+
|---|---|---|
73+
| **`_calloc_dbg`** | \<crtdbg.h> | The debug C Runtime Library (for example, `ucrtd.lib`). Only available in debug builds. See [CRT library features](../crt-library-features.md). |
7474

7575
For more compatibility information, see [Compatibility](../compatibility.md).
7676

docs/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ For more information, see [Format specification syntax: `printf` and `wprintf` f
109109

110110
## Return value
111111

112-
The number of characters that which would have been written to the buffer if `count` was ignored. The count doesn't include the terminating `NULL` character.
112+
The number of characters that would have been written to the buffer if `count` was ignored. The count doesn't include the terminating `NULL` character.
113113

114114
Let **`len`** be the length of the formatted data string, not including the terminating `NULL`.\
115115
For all functions, if `len < count`, then **`len`** characters are stored in *`buffer`*, a null-terminator is appended, and the number of characters written, not including the terminating `NULL`, is returned.
@@ -120,7 +120,12 @@ See [Behavior summary](#behavior-summary) for details.
120120

121121
## Remarks
122122

123-
Beginning with the UCRT in Visual Studio 2015 and Windows 10, **`snprintf`** is no longer identical to **`_snprintf`**. The **`snprintf`** behavior is now C99 standard conformant. The difference is that if you run out of buffer, `snprintf` null-terminates the end of the buffer and returns the number of characters that would have been required whereas `_snprintf` doesn't null-terminate the buffer and returns -1. Also, `_snprintf()` includes one more character in the output because it doesn't null-terminate the buffer.
123+
Beginning with the UCRT in Visual Studio 2015 and Windows 10, **`snprintf`** is no longer identical to **`_snprintf`**. The **`snprintf`** behavior is now C99 standard conformant. The differences are:
124+
125+
- **`snprintf`** always null-terminates the buffer (even when truncating), and returns the total number of characters that would have been written if the buffer were large enough (not counting the null-terminator).
126+
- **`_snprintf`** does **not** null-terminate the buffer when the output is truncated, and returns **-1** when truncation occurs.
127+
128+
Because `_snprintf` doesn't write a null-terminator when it truncates, it can fit one more data character into the same buffer size. However, the resulting string is not null-terminated, so you must handle termination yourself.
124129

125130
- **`snprintf`** and the **`_snprintf`** family of functions format and store *`count`* or fewer characters in *`buffer`*.
126131
- **`snprintf`** always stores a terminating `NULL` character, truncating the output if necessary.

docs/c-runtime-library/reference/wcstombs-s-wcstombs-s-l.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ By default, this function's global state is scoped to the application. To change
114114

115115
## Requirements
116116

117-
| Routine | Required header |
118-
|---|---|
119-
| **`wcstombs_s`** | `<stdlib.h>` |
117+
| Routine | Required header | Required library |
118+
|---|---|---|
119+
| **`wcstombs_s`** | `<stdlib.h>` | The Universal C Runtime Library (UCRT). Linked automatically when you build with the Visual C++ compiler. |
120120

121121
For more compatibility information, see [Compatibility](../compatibility.md).
122122

docs/code-quality/c6387.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ helpviewer_keywords: ["C6387"]
1313

1414
This warning is raised if an annotated function parameter is being passed an unexpected value. For example, passing a potentially null value to a parameter that is marked with `_In_` annotation generates this warning.
1515

16+
This commonly happens when one function is annotated with `_Post_ _Null_` on its return value (meaning it may return null), and the result is then passed to another function that expects a non-null `_In_` parameter. To fix the issue, either change the first function's annotation to `_Post_ _Notnull_` if it truly never returns null, or add a null check before passing the value to the second function.
17+
18+
> [!NOTE]
19+
> The SAL annotations (`_Post_ _Null_`, `_Post_ _Notnull_`, `_In_`, etc.) are used on function declarations to describe the contract of the function's parameters and return values. They do not apply to local variable declarations.
20+
1621
Code analysis name: `INVALID_PARAM_VALUE_1`
1722

1823
## Example
1924

20-
The following code generates this warning because a null parameter is passed to `f(char *)`:
25+
The following code generates this warning because the function `g` is annotated as potentially returning null (`_Post_ _Null_`), and the result is passed to `f`, which requires a non-null input (`_In_`):
2126

2227
```cpp
2328
#include <sal.h>
@@ -33,7 +38,7 @@ int main()
3338
}
3439
```
3540
36-
To correct this warning, use the following code:
41+
To correct this warning, you can change the annotation on `g` if it never actually returns null:
3742
3843
```cpp
3944
#include <sal.h>
@@ -49,6 +54,25 @@ int main()
4954
}
5055
```
5156

57+
Alternatively, you can add a null check before passing the value:
58+
59+
```cpp
60+
#include <sal.h>
61+
62+
_Post_ _Null_ char * g();
63+
64+
void f(_In_ char *pch);
65+
66+
int main()
67+
{
68+
char *pCh = g();
69+
if (pCh != nullptr)
70+
{
71+
f(pCh);
72+
}
73+
}
74+
```
75+
5276
## See also
5377
5478
[strlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l](../c-runtime-library/reference/strlen-wcslen-mbslen-mbslen-l-mbstrlen-mbstrlen-l.md)

docs/code-quality/how-to-set-code-analysis-properties-for-c-cpp-projects.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ ms.assetid: 7af52097-6d44-4785-9b9f-43b7a7d447d7
1818

1919
You can configure which rules the code analysis tool uses to analyze the code in each configuration of your project. In addition, you can direct code analysis to suppress warnings from code that was generated and added to your project by a third-party tool.
2020

21+
> [!NOTE]
22+
> In recent versions of Visual Studio, the legacy **Code Analysis** property page in the project properties dialog may appear empty or show a deprecation notice. Use the individual settings described below to configure code analysis. For CMake projects, use `CMakeSettings.json` or `CMakePresets.json` instead.
23+
2124
## Code Analysis Property Page
2225

2326
The **Code Analysis** property page contains all code analysis configuration settings for an MSBuild project. To open the code analysis property page for a project in **Solution Explorer**, right-click the project and then click **Properties**. Next, expand **Configuration Properties** and select the **Code Analysis** tab.

docs/cpp/abstract-classes-cpp.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ The only difference between this declaration and the previous one is that `Print
3131
3232
Abstract classes can't be used for:
3333
34-
- Variables or member data
34+
- Variables or member data (you can't declare a variable of an abstract class type)
3535
36-
- Argument types
36+
- Argument types (you can't pass an abstract class by value as a function parameter)
3737
38-
- Function return types
38+
- Function return types (a function can't return an abstract class by value)
3939
40-
- Types of explicit conversions
40+
- Types of explicit conversions (you can't cast to an abstract class type)
41+
42+
In each case, you can use pointers or references to the abstract class type instead. For example, a function can take `AbstractBase&` or `AbstractBase*` as a parameter, and you can declare pointers or references of the abstract class type.
4143
4244
If the constructor for an abstract class calls a pure virtual function, either directly or indirectly, the result is undefined. However, constructors and destructors for abstract classes can call other member functions.
4345

docs/error-messages/tool-errors/linker-tools-error-lnk1140.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ helpviewer_keywords: ["LNK1140"]
1111
1212
## Remarks
1313

14-
The project contains more than 4096 modules.
14+
The project exceeds the maximum number of modules allowed in a program database (PDB) file. This limit was originally 4,096 modules and was later increased to 65,535.
15+
16+
This error can also occur when other PDB size limits are exceeded, such as very large symbol tables or an excessive number of type records.
1517

1618
### To fix by using the following possible solutions
1719

@@ -20,3 +22,5 @@ The project contains more than 4096 modules.
2022
1. Compile some modules without debugging information.
2123

2224
1. Reduce the number of modules.
25+
26+
1. Split your project into multiple smaller libraries or DLLs.

docs/error-messages/tool-errors/linker-tools-errors-and-warnings.md

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)