Where are the additional C11 macros?

The C11 standard states that compilers must provide some macros to check for additional functions. What headlines do I find them in?

For example, where is it located __STDC_NO_VLA__?

With GCC, that is, if I try to find __STDC_NO_COMPLEX__in complex.h, I will not find it there ...

+4
source share
2 answers

They are not defined in any header, the compiler will define them.

You can reset all preprocessors. For example, for gcc write:

gcc -dM -E - < /dev/null

For example, for me:

bob@bob-fedora:~/trunk/software$ gcc --version
gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bob@bob-fedora:~/trunk/software$ gcc -std=gnu11 -dM -E - < /dev/null | grep STDC
#define __STDC_HOSTED__ 1
#define __STDC_UTF_16__ 1
#define __STDC_VERSION__ 201112L
#define __GNUC_STDC_INLINE__ 1
#define __STDC_UTF_32__ 1
#define __STDC__ 1

In the above example, the __STDC_NO_VLA__presence of this means that the compiler does not support arrays of variable length. You can write:

#ifdef __STDC_NO_VLA__
#error Your compiler does not support VLAs! Please use a supported compiler.
#endif

or

#ifndef __STDC_NO_VLA__
// code using variable length arrays
#else
// fallback code for when they are not supported
#endif
+6
source

STDC_NO_COMPLEX, , complex.h

STDC_NO_COMPLEX ,

: http://en.cppreference.com/w/c/numeric/complex

+1

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


All Articles