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
-2
votes
1 answer

Works on gcc c11, but on Clang 3.6 c11 I get malloc(): memory corruption (fast): 0x0000000000fb8620

I have this program. When I run in on gcc using gcc egyptionFractions.c -o egypt -Wall -std=c11, it works great! However, I am trying to run it using llvm on a server and I continually get this error: * Error in `/home/codewarrior/solution':…
Ryan
  • 436
  • 5
  • 15
-2
votes
1 answer

c11: use _Generic raise SIGSEGV

here is my code, I try sample code from here #include #define type_idx(T) _Generic( (T), char: 1, int: 2, long: 3, default: 0) int main(int argc, char *argv[]) { puts(type_idx("smth")); } the output in clion…
nwaicaethi
  • 175
  • 3
  • 10
-2
votes
1 answer

Why are _Generic statements treated like expressions rather than macros?

I am setting up some large width integer types, and so I am making heavy use of macros to make the types usable as much as possible like the basic integer types. An issue I keep running into is that I can have the most straightforward and easily…
jack
  • 282
  • 2
  • 9
-2
votes
2 answers

C11 network programming

I've been reading Beej's Guide to Network Programming and tried to compile the first few example programs (section 5.1) using the std=c11 flag with gcc. I keep getting errors like these (showip.c): showip.c: In function ‘main’: showip.c:15:21:…
John Bergson
  • 425
  • 1
  • 4
  • 7
-3
votes
1 answer

If an implementation supports extra nonstandard features, then is such implementation conforming?

Follow-up question for: Do unsupported standard features affect conformance?. Question: if an implementation supports extra features which are not described in the C standard, nor in any "extension document", then is such implementation…
pmor
  • 5,392
  • 4
  • 17
  • 36
-3
votes
1 answer

Why quiet NaN is not always quiet and may lead to raising of floating-point exceptions?

Context: the quiet NaN is not always quiet and may lead to raising of floating-point exceptions. Code sample & invocations: see QNAN passed into C standard library functions (ex. llrintf): not clear whether FP exceptions are raised or not. Details:…
pmor
  • 5,392
  • 4
  • 17
  • 36
-3
votes
2 answers

What rules in C11 standard determine the evaluation of `int tx = INT_MAX +1`?

int tx = INT_MAX +1; // 2147483648; printf("tx = %d\n", tx); prints tx = -2147483648. I was…
Tim
  • 1
  • 141
  • 372
  • 590
-3
votes
3 answers

What is the greatest number of unique keywords you can add to a variable in C?

I was writing some code in C and I wrote: static const unsigned char foo[]. Which made me wonder, what is the greatest number of unique keywords (and what are those keywords) that I can add in front of a variable in valid c11?
Axel Munoz
  • 77
  • 3
-3
votes
3 answers

Is there a way to find array length in a function without passing an argument?

Is there a way I could get the length of an array inside a function? I need to find the size of an array, however it is defined in the main function and I cannot pass the array size as an argument as I cannot change the main function. So is there…
TheKingSid
  • 39
  • 6
-3
votes
1 answer

Quick question, why is scanf_s throwing an exception in runtime here? I am very confused

I am trying to use scanf (or some variant like scanf_s) to send a character array from the stdin stream into a (pre-defined) character array variable. The error (unhanled exception) is thrown at runtime by windows as soon as the user hits enter; it…
-3
votes
1 answer

Difference between scanf and scanf_s in C

Although my program gives the required output. There are many warnings showing scanf() shouldn't be used and try using scanf_s() instead. Possible cause of this warning?? This is happening to all the programs which are using the scanf function.…
user3743672
  • 151
  • 5
-4
votes
1 answer

Why isn't an IEC 60559 conformant implementation required to define __STDC_IEC_559__ (to 1)?

The C (C99+) standard requires (though implicitly) a conforming implementation to define __STDC__ to 1. However, the C standard does not require an IEC 60559 conformant implementation to define __STDC_IEC_559__ (to 1). Consequences: #if __STDC__ !=…
pmor
  • 5,392
  • 4
  • 17
  • 36
-4
votes
2 answers

What does the 'tm' in `struct tm` stand for?

Just curious. I've tended to name variables of the type struct tm something like time_bits or similar, since it contains the broken-down calendar time bits. Most of the documentation I've seen refers to this type as 'calendar time', as opposed to…
Huckle
  • 1,810
  • 3
  • 26
  • 40
-4
votes
2 answers

How to understand the conversion rule when a "pointer to an object type" compares for eqality with a "pointer to a void"?

n1570 6.5.9.5 (Equality operators) says: 5 ......If one operand is a pointer to an object type and the other is a pointer to a qualified or unqualified version of void, the former is converted to the type of the latter. If "former" is "latter"…
user3528438
  • 2,737
  • 2
  • 23
  • 42
-4
votes
2 answers

library in C11 or C99 good practice

What is better idea: write library which will be used by others in C11 or C99? Is it good justification that many people rather use C99 in theis project than C11 or it's not true? And what is better for microcontrollers? I am not professional and I…
Edison91
  • 25
  • 4
1 2 3
58
59