A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/algorithm/../../cpp/../c/language/../program/memalignment.html below:

memalignment - cppreference.com

size_t memalignment( const void *p ); (since C23)

Returns the maximum alignment satisfied by the provided address. The return value can be greater than any alignment value supported by the implementation. If p is a null pointer value, ​0​ is returned to indicate that the pointer cannot be used to access an object of any type.

If the return value compares is greater than or equal to alignof(T), the alignment requirement for the type T is satisfied by the pointer.

A freestanding implementation needs to provide memalignment.

[edit] Parameters p - pointer to query alignment [edit] Return value

The alignment value of p, or ​0​ if p is a null pointer value.

[edit] Notes

On common platforms where

this function can be implemented as return (size_t)p & -(size_t)p;.

[edit] Example
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    alignas(128) int i = 0;
    printf("%zu\n%zu\n", memalignment(nullptr), memalignment(&i));
}

Possible output:

[edit] References
[edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4