Questions tagged [c11]

C11 is the informal name of an older standard version (ISO/IEC 9899:2011) of the C programming language.

Important Note: All C related questions, shall be tagged as , and then as a complement, each should specify the version of the standard it is using. In case of C11, this complement should be the tag.

Detection

A standard macro __STDC_VERSION__ is defined with the value 201112L to indicate that C11 support is available. See corr 1:2012.

Some of the changes since :

  • _Alignas specifier (and optionally the alignas macro)
  • _Alignof operator (and optionally the alignof macro)
  • _Noreturn function specifier (and optionally the noreturn macro)
  • _Generic keyword
  • _Static_assert keyword (and optionally the static_assert macro)
  • _Thread_local storage-class specifier (and optionally the thread_local macro)
  • _Atomic type qualifier
  • _Complex and _Imaginary keywords (and optionally the complex and imaginary macros)
  • once_flag, cnd_t, mtx_t, thrd_t, thrd_start_t, tss_t and tss_dtor_t types
  • char16_t and char32_t types
  • anonymous struct and union support
  • aligned_alloc function
  • quick_exit function
  • gets_s function in much-rejected optional Annex K (see ) as an alternative to the removed gets

More Info:

875 questions
18
votes
1 answer

Branchless conditionals on integers — fast, but can they be made faster?

I've been experimenting with the following and have noticed that the branchless “if” defined here (now with &-!! replacing *!!) can speed up certain bottleneck code by as much as (almost) 2x on 64-bit Intel targets with clang: // Produces x if f is…
Todd Lehman
  • 2,880
  • 1
  • 26
  • 32
18
votes
2 answers

uchar.h file not found on OS X 10.9

I'm under the impression my C compiler supports C11 since it accepts the -std=c11 flag, $ cc --version Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.3.0 Thread model: posix and uchar.h is part of the…
user3679630
17
votes
2 answers

Bit-fields and sequence points

For an implementation that packs f0 and f1 into the same byte, is the program below defined? struct S0 { unsigned f0:4; signed f1:4; } l_62; int main (void) { (l_62.f0 = 0) + (l_62.f1 = 0); return 0; } I am interested…
Pascal Cuoq
  • 79,187
  • 7
  • 161
  • 281
17
votes
2 answers

What does C1x inherit from C++?

It is well known that both C++ takes features from C but that C also standardizes C++ features. C1x has gained full expression temporaries (previously it only had sequence point temporaries). C1x also took from the C++11 threading effort. I wonder…
Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
17
votes
3 answers

Does ISO C allow aliasing of the argv[] pointers supplied to main()?

ISO C requires that hosted implementations call a function named main. If the program receives arguments, they are received as an array of char* pointers, the second argument in main's definition int main(int argc, char* argv[]). ISO C also requires…
Iwillnotexist Idonotexist
  • 13,297
  • 4
  • 43
  • 66
17
votes
4 answers

Why does mismatched prototype and definition with empty argument list give different results in GCC and Clang?

Given (simplified) code snippet: void foo(int a, int b); // declaration with prototype int main(void) { foo(1, 5); // type-checked call (i.e. because of previous prototype) return 0; } void foo() // old-style definition (with empty…
Grzegorz Szpetkowski
  • 36,988
  • 6
  • 90
  • 137
17
votes
4 answers

Compatibility of C89/C90, C99 and C11

I just read: C Wikipedia entry. As far as I know there are 3 different versions of C that are widely used: C89, C99 and C11. My question concerns the compatibility of source code of different versions. Suppose I am going to write a program (in C11…
Michael S
  • 466
  • 1
  • 4
  • 12
17
votes
5 answers

Why is there no ASCII or UTF-8 character literal in C11 or C++11?

Why is there no UTF-8 character literal in C11 or C++11 even though there are UTF-8 string literals? I understand that, generally-speaking, a character literal represents a single ASCII character which is identical to a single-octet UTF-8 code…
jbatez
  • 1,772
  • 14
  • 26
16
votes
5 answers

C1x: When will it land, what to expect?

C99 still isn't supported by many compilers, and much of the focus is now on C++, and its upcoming standard C++1x. I'm curious as to what C will "get" in its next standard, when it will get it, and how it will keep C competitive. C and C++ are known…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
16
votes
3 answers

Parameters declared restrict and compiler warnings

Neither gcc 5 nor clang 3.6 give warnings where the constraints of the restrict qualifier are violated, even when called with -Wall. Consider the following code fragment: extern void f(char *restrict p, char *restrict q); void g(char *p) { …
jch
  • 5,382
  • 22
  • 41
16
votes
4 answers

Is (uint64_t)-1 guaranteed to yield 0xffffffffffffffff?

I know, that it is well defined by the C standard that (unsigned)-1 must yield 2^n-1, i. e. an unsigned integer with all its bits set. The same goes for (uint64_t)-1ll. However, I cannot find something in the C11 standard that specifies how…
cmaster - reinstate monica
  • 38,891
  • 9
  • 62
  • 106
16
votes
1 answer

What is C11 cor 1:2012?

I just noticed that there has been a correction to the C11 standard called ISO/IEC 9899:2011/Cor 1:2012. What was changed in this update?
Lundin
  • 195,001
  • 40
  • 254
  • 396
15
votes
2 answers

Is this a valid way of checking if a variadic macro argument list is empty?

I've been looking for a way to check if a variadic macro argument list is empty. All solutions I find seem to be either quite complex or using non-standard extensions. I think I've found an easy solution that is both compact and standard: #define…
Lundin
  • 195,001
  • 40
  • 254
  • 396
15
votes
2 answers

Memory position of elements in C/C++ union

I have a union in C like this: union AUnion { struct CharBuf { char *buf; size_t len; } charbuf; uint8_t num; double fp_num; }; My question is, can I guarantee that if given the following: union AUnion u; Then the following are…
A_User
  • 397
  • 1
  • 9
15
votes
1 answer

error: use of undeclared identifier 'errno_t'

Here is my dead simple dummy code: #include int main(void) { errno_t e; return 0; } Which surprisingly raises this error: main.c:5:5: error: use of undeclared identifier 'errno_t' errno_t x; ^ I started to follow the…
Peter Varo
  • 11,726
  • 7
  • 55
  • 77