<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFSTR",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@macro@CFSTR"
  },
  "title" : "CFSTR"
}
-->

# CFSTR

Creates an immutable string from a constant compile-time string.

```
#define CFSTR(cStr)
```

## Parameters

`cStr`

A constant C string (that is, text enclosed in double-quotation marks) from which the string is to be created.

## Return Value

An immutable string, or `NULL` if there was a problem creating the object. The returned object is a constant. You may retain and release it, similar to other immutable CFString objects, but are not required to do so—it will remain valid until the program terminates.

## Discussion

The `CFSTR` macro is a convenient way to create CFString representations of constant compile-time strings.

A value returned by `CFSTR` has the following semantics:

- Values returned from `CFSTR` are not released by CFString—they are guaranteed to be valid until the program terminates.
- You can retain and release values returned from `CFSTR` in a balanced fashion, like any other CFString, but you are not required to do so.

> Note:
> When using this macro as an initializer, you must build using the `-fconstant-cfstrings` compiler flag.

---

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)