Skip to content

Commit f7bfb6d

Browse files
authored
Merge pull request #3465 from MicrosoftDocs/master
3/26/2021 AM Publish
2 parents bf6d8a2 + 366d269 commit f7bfb6d

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

docs/build/walkthrough-compiling-a-native-cpp-program-on-the-command-line.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Walkthrough: Compiling a Native C++ Program on the Command Line"
33
description: "Use the Microsoft C++ compiler from a command prompt."
44
ms.custom: "conceptual"
5-
ms.date: "04/02/2020"
5+
ms.date: 03/25/2021
66
helpviewer_keywords: ["native code [C++]", "Visual C++, native code", "compiling programs [C++]", "command-line applications [C++], native"]
77
ms.assetid: b200cfd1-0440-498f-90ee-7ecf92492dc0
88
---
@@ -57,11 +57,11 @@ Before you can build a C or C++ program on the command line, verify that the too
5757
5858
### Create a Visual C++ source file and compile it on the command line
5959

60-
1. In the developer command prompt window, enter `md c:\hello` to create a directory, and then enter `cd c:\hello` to change to that directory. This directory is where your source file and the compiled program are created in.
60+
1. In the developer command prompt window, enter `md c:\hello` to create a directory, and then enter `cd c:\hello` to change to that directory. This directory is where both your source file and the compiled program get created.
6161

6262
1. Enter `notepad hello.cpp` in the command prompt window.
6363

64-
Choose **Yes** when Notepad prompts you to create a file. This step opens a blank Notepad window, ready for you to enter your code in a file named hello.cpp.
64+
Choose **Yes** when Notepad prompts you to create a new file. This step opens a blank Notepad window, ready for you to enter your code in a file named hello.cpp.
6565

6666
1. In Notepad, enter the following lines of code:
6767

@@ -97,7 +97,10 @@ Before you can build a C or C++ program on the command line, verify that the too
9797
9898
```
9999

100-
The dates and other details will differ on your computer. If you don't see your source code file, *hello.cpp*, make sure you've changed to the *c:\\hello* directory you created. In Notepad, make sure that you saved your source file in this directory. Also make sure that you saved the source code with a *`.cpp`* file name extension, not a *`.txt`* extension.
100+
The dates and other details will differ on your computer.
101+
102+
> [!NOTE]
103+
> If you don't see your source code file, *`hello.cpp`*, make sure the current working directory in your command prompt is the *`C:\hello`* directory you created. Also make sure that this is the directory where you saved your source file. And make sure that you saved the source code with a *`.cpp`* file name extension, not a *`.txt`* extension. Your source file gets saved in the current directory as a *`.cpp`* file automatically if you open Notepad at the command prompt by using the **`notepad hello.cpp`** command. Notepad's behavior is different if you open it another way: By default, Notepad appends a *`.txt`* extension to new files when you save them. It also defaults to saving files in your *Documents* directory. To save your file with a *`.cpp`* extension in Notepad, choose **File** > **Save As**. In the **Save As** dialog, navigate to your *`C:\hello`* folder in the directory tree view control. Then use the **Save as type** dropdown control to select **All Files (\*.\*)**. Enter *`hello.cpp`* in the **File name** edit control, and then choose **Save** to save the file.
101104
102105
1. At the developer command prompt, enter `cl /EHsc hello.cpp` to compile your program.
103106

docs/c-runtime-library/reference/strncat-s-strncat-s-l-wcsncat-s-wcsncat-s-l-mbsncat-s-mbsncat-s-l.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l"
33
title: "strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l"
4-
ms.date: "4/2/2020"
4+
ms.date: "3/25/2021"
55
api_name: ["_wcsncat_s_l", "wcsncat_s", "_mbsncat_s_l", "_mbsncat_s", "strncat_s", "_strncat_s_l", "_o__mbsncat_s", "_o__mbsncat_s_l", "_o_strncat_s", "_o_wcsncat_s"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-multibyte-l1-1-0.dll", "api-ms-win-crt-string-l1-1-0.dll", "ntoskrnl.exe", "api-ms-win-crt-private-l1-1-0.dll"]
77
api_type: ["DLLExport"]
@@ -133,7 +133,7 @@ Returns 0 if successful, an error code on failure.
133133

134134
These functions try to append the first *D* characters of *strSource* to the end of *strDest*, where *D* is the lesser of *count* and the length of *strSource*. If appending those *D* characters will fit within *strDest* (whose size is given as *numberOfElements*) and still leave room for a null terminator, then those characters are appended, starting at the original terminating null of *strDest*, and a new terminating null is appended; otherwise, *strDest*[0] is set to the null character and the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md).
135135

136-
There is an exception to the above paragraph. If *count* is [_TRUNCATE](../../c-runtime-library/truncate.md) then as much of *strSource* as will fit is appended to *strDest* while still leaving room to append a terminating null.
136+
There is an exception to the above paragraph. If *count* is [_TRUNCATE](../../c-runtime-library/truncate.md), then as much of *strSource* as will fit is appended to *strDest* while still leaving room to append a terminating null.
137137

138138
For example,
139139

@@ -143,9 +143,9 @@ strncpy_s(dst, _countof(dst), "12", 2);
143143
strncat_s(dst, _countof(dst), "34567", 3);
144144
```
145145
146-
means that we are asking **strncat_s** to append three characters to two characters in a buffer five characters long; this would leave no space for the null terminator, hence **strncat_s** zeroes out the string and calls the invalid parameter handler.
146+
means that we're asking **strncat_s** to append three characters to two characters in a buffer five characters long; this would leave no space for the null terminator, hence **strncat_s** zeroes out the string and calls the invalid parameter handler.
147147
148-
If truncation behavior is needed, use **_TRUNCATE** or adjust the *size* parameter accordingly:
148+
If truncation behavior is needed, use **_TRUNCATE** or adjust the *count* parameter accordingly:
149149
150150
```C
151151
strncat_s(dst, _countof(dst), "34567", _TRUNCATE);
@@ -159,11 +159,11 @@ strncat_s(dst, _countof(dst), "34567", _countof(dst)-strlen(dst)-1);
159159
160160
In all cases, the resulting string is terminated with a null character. If copying takes place between strings that overlap, the behavior is undefined.
161161
162-
If *strSource* or *strDest* is **NULL**, or is *numberOfElements* is zero, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md) . If execution is allowed to continue, the function returns **EINVAL** without modifying its parameters.
162+
If *strSource* or *strDest* is **NULL**, or *numberOfElements* is zero, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md) . If execution is allowed to continue, the function returns **EINVAL** without modifying its parameters.
163163
164164
**wcsncat_s** and **_mbsncat_s** are wide-character and multibyte-character versions of **strncat_s**. The string arguments and return value of **wcsncat_s** are wide-character strings; those of **_mbsncat_s** are multibyte-character strings. These three functions behave identically otherwise.
165165
166-
The output value is affected by the setting of the **LC_CTYPE** category setting of the locale; see [setlocale](setlocale-wsetlocale.md) for more information. The versions of these functions without the **_l** suffix use the current locale for this locale-dependent behavior; the versions with the **_l** suffix are identical except that they use the locale parameter passed in instead. For more information, see [Locale](../../c-runtime-library/locale.md).
166+
The output value is affected by the setting of the **LC_CTYPE** category setting of the locale. For more information, see [setlocale](setlocale-wsetlocale.md). The versions of these functions without the **_l** suffix use the current locale for this locale-dependent behavior; the versions with the **_l** suffix are identical except they use the locale parameter passed in instead. For more information, see [Locale](../../c-runtime-library/locale.md).
167167
168168
In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically (eliminating the need to specify a size argument) and they can automatically replace older, non-secure functions with their newer, secure counterparts. For more information, see [Secure Template Overloads](../../c-runtime-library/secure-template-overloads.md).
169169
@@ -178,7 +178,7 @@ By default, this function's global state is scoped to the application. To change
178178
|**_tcsncat_s**|**strncat_s**|**_mbsnbcat_s**|**wcsncat_s**|
179179
|**_tcsncat_s_l**|**_strncat_s_l**|**_mbsnbcat_s_l**|**_wcsncat_s_l**|
180180
181-
**_strncat_s_l** and **_wcsncat_s_l** have no locale dependence; they are only provided for **_tcsncat_s_l**.
181+
**_strncat_s_l** and **_wcsncat_s_l** have no locale dependence; they're are only provided for **_tcsncat_s_l**.
182182
183183
## Requirements
184184
@@ -188,7 +188,7 @@ By default, this function's global state is scoped to the application. To change
188188
|**wcsncat_s**|\<string.h> or \<wchar.h>|
189189
|**_mbsncat_s**, **_mbsncat_s_l**|\<mbstring.h>|
190190
191-
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
191+
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
192192
193193
## Example
194194

docs/code-quality/c26497.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: CppCoreCheck rule that enforces C++ Core Guidelines F.4
88
---
99
# C26497 USE_CONSTEXPR_FOR_FUNCTION
1010

11-
This function %function% could be marked `constexpr` if compile-time evaluation is desired (f.4).
11+
> This function *function-name* could be marked `constexpr` if compile-time evaluation is desired (f.4).
1212
1313
## See also
1414

@@ -24,3 +24,12 @@ void function1() noexcept
2424
const int theAnswer = GetTheAnswer(0);
2525
}
2626
```
27+
28+
To reduce code analysis noise on new code, this warning isn't issued if the function has an empty implementation.
29+
30+
```cpp
31+
int function1(){ // no C26497
32+
return 1;
33+
}
34+
void function2(){} // no C26497
35+
```

0 commit comments

Comments
 (0)