The C11 standard added a few new keywords to the language. These are often called the “underscore keywords” because each is prefixed with an underscore. The second letter is often capitalized, as is the case with _Alignof.
I’m unsure of when the _Alignof operator is necessary, but obviously more than one coder needed it because it was added to the language in 2011. The keyword has been deprecated with the C23 standard, not because it’s dangerous or too weird but because it’s been replaced by the more official alignof operator.
Here is the operator’s format:
size_t _Alignof(type name);
(C11)
size_t alignof(type name);
(C23)
The type name is either a data type or an identifier (variable name). The value returned is an integer that describes the memory alignment of the type examined. To explain what all this means, you need to know how data is arranged in memory.
The computer doesn’t store data at haphazard locations. Data is aligned at certain locations or offsets because the processor more efficiently fetches data in this manner. For example, less overhead is required to read a 16-bit integer when it’s aligned in memory at address 0x12A0 than were the integer stored at address 0x12A3. The _Alignof operator determines how the data is aligned based on its size in memory.
The following code outputs three tidbits for three different data types.
2025_06_21-Lesson.c
//https://en.cppreference.com/w/c/language/object#Alignment #include <stdio.h> struct alpha { char c; int i; }; int main() { struct alpha a; char string[] = "abcdefghijk"; int beta = 0; printf("The structure occupies %zu bytes\n",sizeof(struct alpha) ); printf("The structure aligns at %zu bytes\n",_Alignof(struct alpha) ); printf("The structure sits at location %p\n",&a); printf("The string occupies %zu bytes\n",sizeof(string) ); printf("The string aligns at %zu bytes\n",_Alignof(string) ); printf("The string sits at location %p\n",string); printf("The integer occupies %zu bytes\n",sizeof(beta) ); printf("The integer aligns at %zu bytes\n",_Alignof(beta) ); printf("The integer sits at location %p\n",&beta); return 0; }
For each data type — structure, string, and integers — three values are output: The size of the data in memory, the alignment, and its memory location. Here’s sample output on my system:
The structure occupies 8 bytes
The structure aligns at 4 bytes
The structure sits at location 0x7ffe0c2c4e30
The string occupies 12 bytes
The string aligns at 1 bytes
The string sits at location 0x7ffe0c2c4e24
The integer occupies 4 bytes
The integer aligns at 4 bytes
The integer sits at location 0x7ffe0c2c4e20
The structure aligns at 4 bytes, probably because the integer memory requires 4 bytes of storage, which is just a guess on my part.
The string occupies 12 bytes, but can align at any location. Strings are character arrays, and a character can dwell at any specific location in memory without annoying the processor.
The integer occupies 4 bytes and is aligned at 4 byte offsets.
If I modify the structure to contain a long instead of an int, the first few lines of output appear as:
The structure occupies 16 bytes
The structure aligns at 8 bytes
The structure sits at location 0x7ffcfc806038
...
A long occupies 8 bytes of memory, so it’s aligned at 8-byte offsets. The structure expands to fill 16 bytes of memory, even though its other member is just a character. Figure 1 illustrates why this alignment is necessary and how it works.

Figure 1. How a structure may align in memory due to its members’ data types.
From Figure 1, consider that the compiler knows that it must align a long member of the structure at an 8-byte boundary, which is why the structure occupies 16 bytes. The allocation shows some wasted space, but I believe it makes accessing the structure’s data more efficient as a trade-off.
All this information is interesting to examine, and it may help you to understand how data is stored in computer memory. But to apply a practical application or need for the _Alignof/alignof operator continues to puzzle me. Even so, it’s been considered necessary in C, even updated with the current C23 standard.
As nobody else has come up with any ideas I thought I’d chip in with a bit of speculation.
Maybe it would be useful for coding complex data structures where you malloc a whole load of memory in one go and then write to various parts of it. The alignof function could then be used to make sure you write to a multiple of the alignment for the particular type.
That’s an excellent justification.
Another one I thought of is just internal use by the compiler for pretty much doing the same thing.