<!--
{
  "availability" : [
    "SwiftPM: 6.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/CSetting/treatWarning(_:as:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription8CSettingV12treatWarning_2as_ACSS_AA0E5LevelOAA21BuildSettingConditionVSgtFZ"
  },
  "title" : "treatWarning(_:as:_:)"
}
-->

# treatWarning(_:as:_:)

Controls how a specific C compiler warning is treated during compilation.

```
static func treatWarning(_ name: String, as level: WarningLevel, _ condition: BuildSettingCondition? = nil) -> CSetting
```

## Parameters

`name`

The name of the specific warning to control.

`level`

The treatment level for the warning (`.warning` or `.error`).

`condition`

A condition that restricts the application of the build setting.

## Discussion

Use this setting to specify whether a particular warning should be treated as a warning
(default behavior) or as an error. This is equivalent to passing `-Werror=` or `-Wno-error=`
followed by the warning name to the C compiler.

This setting allows for fine-grained control over individual warnings. To control all
warnings at once, use `treatAllWarnings(as:_:)` instead.

> Since: First available in PackageDescription 6.2.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)