Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions docs/build/reference/internal-partition.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
---
title: "/internalPartition"
description: "Use the /internalPartition compiler option to treat the input file as an internal partition unit."
ms.date: 04/15/2022
ms.date: 04/18/2022
author: "tylermsft"
ms.author: "twhitney"
f1_keywords: ["/internalPartition", "VC.Project.VCCLCompilerTool.Interface"]
helpviewer_keywords: ["/internalPartition", "Translate include directives into import directives"]
---
# `/internalPartition`

Use this switch to treat the input file on the command line as an [internal partition unit](http://eel.is/c%2B%2Bdraft/module#unit-4.3).
Use the **`/internalPartition`** compiler option to treat the input file as an *internal partition unit*, which is a [module partition implementation unit](../../cpp/modules-cpp.md#implementing-modules) that doesn't contribute to the external interface of the module.

## Syntax

> **`/internalPartition`** *`filename`*

## Remarks

The following example demonstrates using the `/internalPartition` switch:

`m-internals.cpp`:
The following example demonstrates how to use the `/internalPartition` option:

```cpp
// m-internals.cpp
module m:internals;

void internalFunc() {} // cannot have `export` since this is an internal partition
```

`m.ixx`:

```cpp
// m.ixx
export module m;
import :internals; // Cannot export this partition.

Expand All @@ -43,7 +41,7 @@ To compile this interface:
cl /std:c++latest /internalPartition /c m-internals.cpp
```

This switch can't be used with the [`/interface`](interface.md) compiler switch.
This option can't be used with the [`/interface`](interface.md) compiler option.

**`/internalPartition`** is available in Visual Studio 2019 version 16.10, or later.\
**`/internalPartition`** requires [/std:c++20](std-specify-language-standard-version.md) or later.
Expand Down
73 changes: 37 additions & 36 deletions docs/c-runtime-library/reference/matherr.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
---
description: "Learn more about: _matherr"
title: "_matherr"
ms.date: "04/05/2018"
ms.date: "04/18/2012"
api_name: ["_matherr"]
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_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["_matherr", "matherr"]
helpviewer_keywords: ["_matherr function", "matherr function"]
ms.assetid: b600d66e-165a-4608-a856-8fb418d46760
---
# _matherr
# `_matherr`

Handles math errors.

## Syntax

```C
int _matherr( struct _exception * except );
int _matherr(struct _exception *except);
```

### Parameters

*except*<br/>
*`except`*\
Pointer to the structure containing error information.

## Return Value

**_matherr** returns 0 to indicate an error, or a nonzero value to indicate success. If **_matherr** returns 0, an error message can be displayed and **errno** is set to an appropriate error value. If **_matherr** returns a nonzero value, no error message is displayed and **errno** remains unchanged.
**`_matherr`** returns 0 to indicate an error, or a nonzero value to indicate success:
- If **`_matherr`** returns 0, an error message can be displayed and **`errno`** is set to an appropriate error value.
- If **`_matherr`** returns a nonzero value, no error message is displayed and **`errno`** remains unchanged.

For more information about return codes, see [_doserrno, errno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
For more information about return codes, see [`_doserrno`, `errno`, `_sys_errlist`, and `_sys_nerr`](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).

## Remarks

The **_matherr** function processes errors generated by the floating-point functions of the math library. These functions call **_matherr** when an error is detected.
The **`_matherr`** function processes errors generated by the floating-point functions of the math library. These functions call **`_matherr`** when an error is detected. This interaction isn't impacted by the [floating-point mode of the compiler](../../build/reference/fp-specify-floating-point-behavior.md) or the [floating point control word](../../c-runtime-library/reference/control87-controlfp-control87-2.md). Since **`_matherr`** is a library function, math [intrinsic functions](../../intrinsics/compiler-intrinsics.md) won't call it.

For special error handling, you can provide a different definition of **_matherr**. If you use the dynamically linked version of the C run-time library (CRT), you can replace the default **_matherr** routine in a client executable with a user-defined version. However, you cannot replace the default **_matherr** routine in a DLL client of the CRT DLL.
For special error handling, you can provide a different definition of **`_matherr`**. If you use the dynamically linked version of the C run-time library (CRT), you can replace the default **`_matherr`** routine in a client executable with a user-defined version. However, you can't replace the default **`_matherr`** routine in a DLL client of the CRT DLL.

When an error occurs in a math routine, **_matherr** is called with a pointer to an **_exception** type structure (defined in \<math.h>) as an argument. The **_exception** structure contains the following elements.
When an error occurs in a math routine, **`_matherr`** is called with a pointer to an **`_exception`** type structure (defined in `<math.h>`) as an argument. The **`_exception`** structure contains the following elements.

```C
struct _exception
Expand All @@ -50,36 +51,36 @@ struct _exception
};
```

The **type** member specifies the type of math error. It is one of the following values, defined in \<math.h>:
The **`type`** member specifies the type of math error. It's one of the following values, defined in `<math.h>`:

|Macro|Meaning|
|-|-|
| **_DOMAIN** | Argument domain error |
| **_SING** | Argument singularity |
| **_OVERFLOW** | Overflow range error |
| **_PLOSS** | Partial loss of significance |
| **_TLOSS** | Total loss of significance |
| **_UNDERFLOW** | The result is too small to be represented. (This condition is not currently supported.) |
| **`_DOMAIN`** | Argument domain error |
| **`_SING`** | Argument singularity |
| **`_OVERFLOW`** | Overflow range error |
| **`_PLOSS`** | Partial loss of significance |
| **`_TLOSS`** | Total loss of significance |
| **`_UNDERFLOW`** | The result is too small to be represented. (This condition isn't currently supported.) |

The structure member **name** is a pointer to a null-terminated string containing the name of the function that caused the error. The structure members **arg1** and **arg2** specify the values that caused the error. If only one argument is given, it is stored in **arg1**.
The structure member **`name`** is a pointer to a null-terminated string containing the name of the function that caused the error. The structure members **`arg1`** and **`arg2`** specify the values that caused the error. If only one argument is given, it's stored in **`arg1`**.

The default return value for the given error is **retval**. If you change the return value, it must specify whether an error actually occurred.
The default return value for the given error is **`retval`**. If you change the return value, it must specify whether an error actually occurred.

## Requirements

|Routine|Required header|
|-------------|---------------------|
|**_matherr**|\<math.h>|
|**`_matherr`**|`<math.h>`|

For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).

## Example

```C
// crt_matherr.c
/* illustrates writing an error routine for math
* functions. The error function must be:
* _matherr
/* crt_matherr.c
* Illustrates writing an error routine for math
* functions.
* The error handling function must be named _matherr
*/

#include <math.h>
Expand All @@ -102,27 +103,27 @@ int main()
* returns the natural or base-10 logarithm of the absolute value
* of the argument and suppresses the usual error message.
*/
int _matherr( struct _exception *except )
int _matherr(struct _exception *except)
{
/* Handle _DOMAIN errors for log or log10. */
if( except->type == _DOMAIN )
if (except->type == _DOMAIN)
{
if( strcmp( except->name, "log" ) == 0 )
if (strcmp(except->name, "log") == 0)
{
except->retval = log( -(except->arg1) );
printf( "Special: using absolute value: %s: _DOMAIN "
"error\n", except->name );
except->retval = log(-(except->arg1));
printf("Special: using absolute value: %s: _DOMAIN "
"error\n", except->name);
return 1;
}
else if( strcmp( except->name, "log10" ) == 0 )
else if (strcmp(except->name, "log10") == 0)
{
except->retval = log10( -(except->arg1) );
printf( "Special: using absolute value: %s: _DOMAIN "
"error\n", except->name );
except->retval = log10(-(except->arg1));
printf("Special: using absolute value: %s: _DOMAIN "
"error\n", except->name);
return 1;
}
}
printf( "Normal: " );
printf("Normal: ");
return 0; /* Else use the default actions */
}
```
Expand All @@ -137,4 +138,4 @@ Normal: log( 0.0 ) = -inf

## See also

[Floating-Point Support](../../c-runtime-library/floating-point-support.md)<br/>
[Floating-Point Support](../../c-runtime-library/floating-point-support.md)