Why max_align_t not defined in stddef.h in Windows SDK 10.0.20348.0 C17 (/std:c17)

zhimin yuan 0 Reputation points
2024-06-24T13:33:18.9533333+00:00

#include <stdio.h>

#include <stddef.h>

int main(void)

{

printf("%d\n", _Alignof(max_align_t));
```}

This C code, Error: E0020, C2061, in Visual Studio Community 2019 16.11.17, Windows SDK 10.0.20348.0, C17 or C11  

The same error appears in Visual Studio Community 2022, Windows SDK 10.0.22000.0, C17 or C11

 maybe a bug: "max_align_t not defined in stddef.h in Windows SDK"

Welcome to try, Thanks!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,491 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,431 Reputation points Microsoft Vendor
    2024-06-25T01:50:14.59+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I suggest you could try to use #include <cstddef> instead of #include <stddef.h>.

    It seems that it's only supported in C++ right now. There is no definition of max_align_t in stddef.h.

    And someone has raised a similar issue but it was closed because it was lower priority, and if your issue is tricky, I suggest you could post another issue.

    You could also refer to the thread: https://github.com/emscripten-core/emscripten/pull/8908

    Thank you.

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments