Skip to content

Commit 4b1a4b6

Browse files
author
Colin Robertson
committed
Address thread-safety issue 1827
1 parent 29edbe6 commit 4b1a4b6

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

docs/c-runtime-library/reference/strerror-strerror-wcserror-wcserror.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "strerror, _strerror, _wcserror, __wcserror"
3-
ms.date: "11/04/2016"
3+
description: "Describes the Microsoft C Runtime Library (CRT) functions strerror, _strerror, _wcserror, and __wcserror."
4+
ms.date: "01/07/2020"
45
api_name: ["strerror", "_strerror", "_wcserror", "__wcserror"]
56
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-runtime-l1-1-0.dll"]
67
api_type: ["DLLExport"]
@@ -32,36 +33,36 @@ wchar_t * __wcserror(
3233

3334
### Parameters
3435

35-
*errnum*<br/>
36+
*errnum*\
3637
Error number.
3738

38-
*strErrMsg*<br/>
39+
*strErrMsg*\
3940
User-supplied message.
4041

41-
## Return Value
42+
## Return value
4243

43-
All of these functions return a pointer to the error-message string. Subsequent calls can overwrite the string.
44+
All of these functions return a pointer to an error-message string, in a thread-local storage buffer owned by the runtime. Later calls on the same thread can overwrite this string.
4445

4546
## Remarks
4647

47-
The **strerror** function maps *errnum* to an error-message string and returns a pointer to the string. Neither **strerror** nor **_strerror** actually prints the message: For that, you have to call an output function such as [fprintf](fprintf-fprintf-l-fwprintf-fwprintf-l.md):
48+
The **strerror** function maps *errnum* to an error-message string and returns a pointer to the string. The **strerror** and **_strerror** functions don't actually print the message. To print, call an output function such as [fprintf](fprintf-fprintf-l-fwprintf-fwprintf-l.md):
4849

4950
```C
50-
if (( _access( "datafile",2 )) == -1 )
51+
if (( _access( "datafile", 2 )) == -1 )
5152
fprintf( stderr, _strerror(NULL) );
5253
```
5354
54-
If *strErrMsg* is passed as **NULL**, **_strerror** returns a pointer to a string that contains the system error message for the last library call that produced an error. The error-message string is terminated by the newline character ('\n'). If *strErrMsg* is not equal to **NULL**, then **_strerror** returns a pointer to a string that contains (in order) your string message, a colon, a space, the system error message for the last library call that produces an error, and a newline character. Your string message can be, at most, 94 characters long.
55+
If *strErrMsg* is passed as **NULL**, **_strerror** returns a pointer to a string. It contains the system error message for the last library call that produced an error. The error-message string is terminated by the newline character ('\n'). When *strErrMsg* isn't **NULL**, the string contains, in order: your *strErrMsg* string, a colon, a space, the system error message, and a newline character. Your string message can be, at most, 94 characters long, in either narrow (**_strerror**) or wide (**__wcserror**) characters.
5556
56-
The actual error number for **_strerror** is stored in the variable [errno](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md). To produce accurate results, call **_strerror** immediately after a library routine returns with an error. Otherwise, subsequent calls to **strerror** or **_strerror** can overwrite the **errno** value.
57+
The actual error number for **_strerror** is stored in the variable [errno](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md). To produce accurate results, call **_strerror** immediately after a library routine returns an error. Otherwise, later calls to library routines may overwrite the **errno** value.
5758
5859
**_wcserror** and **__wcserror** are wide-character versions of **strerror** and **_strerror**, respectively.
5960
60-
**_strerror**, **_wcserror**, and **__wcserror** are not part of the ANSI definition; they are Microsoft extensions and we recommend that you do not use them where you want portable code. For ANSI compatibility, use **strerror** instead.
61+
**_strerror**, **_wcserror**, and **__wcserror** are Microsoft-specific, not part of the Standard C library. We don't recommend you use them where you want portable code. For Standard C compatibility, use **strerror** instead.
6162
6263
To get error strings, we recommend **strerror** or **_wcserror** instead of the deprecated macros [_sys_errlist](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) and [_sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md) and the deprecated internal functions **__sys_errlist** and **__sys_nerr**.
6364
64-
### Generic-Text Routine Mappings
65+
### Generic-text routine mappings
6566
6667
|TCHAR.H routine|_UNICODE & _MBCS not defined|_MBCS defined|_UNICODE defined|
6768
|---------------------|------------------------------------|--------------------|-----------------------|
@@ -83,7 +84,7 @@ See the example for [perror](perror-wperror.md).
8384
8485
## See also
8586
86-
[String Manipulation](../../c-runtime-library/string-manipulation-crt.md)<br/>
87-
[clearerr](clearerr.md)<br/>
88-
[ferror](ferror.md)<br/>
89-
[perror, _wperror](perror-wperror.md)<br/>
87+
[String manipulation](../../c-runtime-library/string-manipulation-crt.md)\
88+
[clearerr](clearerr.md)\
89+
[ferror](ferror.md)\
90+
[perror, _wperror](perror-wperror.md)

0 commit comments

Comments
 (0)