Stddef.h enabled but max_align_t not declared

I want to compile this code:

#include <stdalign.h>
#include <stdio.h>
#include <stddef.h>
int main ( int argc , char ** argv )
{
    printf ("%zu\n", alignof ( max_align_t ));
    return 0;
}

But the compiler says that:

error: ‘max_align_t’ undeclared".

stddef.h turned on and everything should be okay, right?

PS I already tried to compile this code under gcc4.8 and gcc4.9, but I have an error as described.

+4
source share
2 answers

To use the C11 function, you need to tell the compiler to work in C11 compatible mode.

For gcc, this can be achieved by specifying an option -std=c11.

+3
source

, c99, stddef.h, . -std = c11, , , -, c11.

0

Source: https://habr.com/ru/post/1611673/


All Articles