---
title: "setConstantValue(_:type:withName:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlfunctionconstantvalues/setconstantvalue(_:type:withname:)"
---

# setConstantValue(_:type:withName:)

Sets a value for a function constant with a specific name.

## Declaration

```swift
func setConstantValue(_ value: UnsafeRawPointer, type: MTLDataType, withName name: String)
```

## Parameters

- `value`: A pointer to the constant value.
- `type`: The data type of the function constant.
- `name`: The name of the function constant.

## Discussion

Discussion The first example declares a single function constant in a Metal Shading Language file. constant bool a [[ function_constant(0) ]]; The next example sets that Boolean value by providing its specific name.

## See Also

### Setting constant values

- [setConstantValue(_:type:index:)](metal/mtlfunctionconstantvalues/setconstantvalue(_:type:index:).md)
- [setConstantValues(_:type:range:)](metal/mtlfunctionconstantvalues/setconstantvalues(_:type:range:).md)
