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
0
votes
0 answers

Compatibility between atomic operations in different C libraries

A classical synchronization idiom between two threads (producer and consumer) involves A producer updating a value in shared memory (global_variable), and then updating an atomic flag (flag) with release semantics. In C11 the producer code could…
user3120046
  • 111
  • 6
0
votes
1 answer

Error status returned by successful thread creation in C

I am trying to write an application in C which uses threads by using thread.h defined in C11 specification. I checked here and here and both resources say that error status are unspecified or ...... Please point me to a source which has this…
user2555595
  • 182
  • 1
  • 4
  • 18
0
votes
0 answers

Can a data race result in something worse than just reading a garbage value?

Both C11 and C++11 standards define that concurrent non-atomic reading and writing the same memory location is a data race which leads to an UB, thus such a program may do virtually anything. OK, got it. I want to understand the reasoning for this…
0
votes
1 answer

What does "__G" signify?

What does __G signify in C? I'm using GCC 4.9. I'm using latest MinGW version. I'm compiling with -std=gnu11. I have the following C (being compiled with GCC as C11) code: #ifndef __G #define __G 0 #endif It compiles fine. But now, while compiling…
user3525723
  • 313
  • 1
  • 8
0
votes
4 answers

Unsigned Bitwise Shift Operators [C11]

Edit: As pointed out below I missed the first part of the ANSI C standard: "If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined." The errors (or rather…
0
votes
1 answer

Slow adoption of C99

I have lately looked at some pages describing adoption of C standard and I was terrified by the fact that C99 (which was created 15 years ago!) is not yet fully supported. Most of the compilers (if not all) does not support full C99 and we already…
Trismegistos
  • 3,821
  • 2
  • 24
  • 41
0
votes
3 answers

block statements, commas, and control expressions in C

I've tried to read the relavent sections of standard (secs 6.5 and 6.8 of c99), but this lead me to be more confused and without a clear answer. This is the code in question: #include #include int t; #define block {\ int temp…
Sam Parker
  • 31
  • 3
0
votes
1 answer

creal and cimag problems with Clang 3.4

I am compiling a library with Petsc using Clang 3.4 and get: error: use of undeclared identifier 'creal' it follows from the following define: petscmath.h:121:38: note: expanded from macro 'PetscRealPartComplex' #define PetscRealPartComplex(a) …
Denis
  • 1,526
  • 6
  • 24
  • 40
0
votes
2 answers

Simple program using strings

I don't know what is wrong with the following code. Maybe scanf_s won't scan the string name. int main(void) { char *name[20]; printf("What is your name>"); scanf_s("%s", name); printf("Your name is %s\n", name); return 0; } I…
0
votes
2 answers

C99 - vscanf for dummies?

I am sorry to bother S.O. with such a general request for information. I can find plenty of very terminology-heavy definitions of vscanf - but I can't find much in the way of concrete examples which will show what is being returned from the…
Benjamin R
  • 555
  • 6
  • 25
0
votes
1 answer

Converting old C99 program to C11 using MinGW

I'm trying to convert an old program that is written in C99 to C11 to be compiled with MinGW. I came across this line of code here contenu[/size] = buffer; and this code output[k] = ((S[(S[i][/i] + S[j])%SIZE]) ^ texte[k]); I'm not used to c99.…
SuicidalCookie
  • 41
  • 1
  • 1
  • 3
0
votes
1 answer

During lvalue conversion, why is the & so special and | never mentioned?

Section §6.3.2.1 (page 72) explains that An lvalue means an object i.e. piece of memory. During evaluation of expressions, the objects are converted to their values i.e. become no longer objects. Notable exceptions are the left operands of =,…
Vorac
  • 8,726
  • 11
  • 58
  • 101
0
votes
1 answer

What is the scope of variables, declared in a "for" condition?

void main(void){ for(int i;;); for(int i;;); } Is this valid C code? What is the scope of i?
Vorac
  • 8,726
  • 11
  • 58
  • 101
0
votes
1 answer

Is it possible to add C11 support to Xcode 4.6?

I'm just wondering if there's a plugin allowing support of C11 in Xcode 4.6.
Jules
  • 14,200
  • 13
  • 56
  • 101
0
votes
1 answer

Extension on shifting or arithemtic operations in standard C

Sorry for bad English. uint16_t a, c; uint8_t b = 0xff; a = b<<8; c = b*10; What is value of a and c we get? What is situation with arbitrary integer types?
user1150105