Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stddef.h is included but max_align_t is undeclared

Tags:

c

gcc

c11

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 compiler says that:

error: ‘max_align_t’ undeclared".

stddef.h is included and everything must be ok, isn't it?

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

like image 368
andrei-volkau Avatar asked Oct 14 '15 20:10

andrei-volkau


1 Answers

To use a C11 feature you need to tell the compiler to run in C11 compliant mode.

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

like image 149
alk Avatar answered Sep 21 '22 14:09

alk