> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C Alignof

The `_Alignof` operator is a unary operator introduced in C11 that evaluates to the alignment requirement of a specified type. It returns the number of bytes representing the boundary on which an object of the given type must be allocated in memory.

```c theme={"dark"}
_Alignof(type-name)
```

## Technical Specifications

* **Return Type:** The operator evaluates to an integer constant expression of type `size_t` (defined in `<stddef.h>`).
* **Operand:** The operand must be a parenthesized type name. Unlike the `sizeof` operator, `_Alignof` cannot accept an expression as its operand.
* **Evaluation:** The result is determined entirely at compile-time.

## Type-Specific Behavior

* **Scalar Types:** Returns the architecture-specific alignment boundary for the type (e.g., `_Alignof(int)` typically returns `4`).
* **Array Types:** When applied to an array type, `_Alignof` evaluates to the alignment requirement of the array's underlying element type, not the alignment of the entire array block.
* **Struct and Union Types:** When applied to a `struct` or `union`, it evaluates to the strictest (largest) alignment requirement among all of its members.

## Constraints and Restrictions

The `_Alignof` operator will result in a compilation error if applied to:

1. Function types.
2. Incomplete types (such as forward-declared structs without a defined body).
3. The `void` type.

## Standard Library Integration

While `_Alignof` is the native keyword, the C standard library provides a convenience macro in the `<stdalign.h>` header:

```c theme={"dark"}
#include <stdalign.h>

// 'alignof' expands directly to '_Alignof'
size_t alignment = alignof(int); 
```

*Note: In the C23 standard, `alignof` becomes a native keyword, making the inclusion of `<stdalign.h>` obsolete for this purpose, though `_Alignof` remains valid for backward compatibility.*

## Syntax Visualization

```c theme={"dark"}
#include <stddef.h>

struct MixedData {
    char a;      // Typically requires 1-byte alignment
    double b;    // Typically requires 8-byte alignment
};

int main(void) {
    // Evaluates to 1
    size_t char_align = _Alignof(char);       
    
    // Evaluates to the alignment of 'int' (e.g., 4)
    size_t array_align = _Alignof(int[10]);   
    
    // Evaluates to the strictest member alignment (e.g., 8 for 'double')
    size_t struct_align = _Alignof(struct MixedData); 

    return 0;
}
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
