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

Is this an equivalent of the compound assignment in C?

Given the following expression, where A and B stand for arbitrary operands (e.g. local or global variables, values returned by functions, etc.) A -= B; Can we always replace this with the following without changing meaning? (type of A)* temp =…
mafu
  • 31,798
  • 42
  • 154
  • 247
-1
votes
2 answers

Efficient conversion from Indeterminate Value to Unspecified Value

Sometimes in C it is necessary to read a possibly-written item from a partially-written array, such that: If the item has been written, the read will yield the value that was in fact written, and If the item hasn't been written, the read will…
supercat
  • 77,689
  • 9
  • 166
  • 211
-1
votes
1 answer

sprintf_s() implicit declaration warning

I have a C code in which I have this line. sprintf_s(var, outfile_ppm, local_filecounter++); Here, var is char* type and local_filecounter is int type. When I run the code it gives me this warning: warning: implicit declaration of function…
npatel
  • 233
  • 3
  • 15
-1
votes
1 answer

gdb optimized out values when using __thread

All my static __thread values shown as when, in debugging, I want to watch the value of a variable; even with -o0 and/or volatile. Static Variables without __thread are shown correctly. Is there anyway to show the values of the…
Max R.
  • 811
  • 1
  • 13
  • 31
-1
votes
3 answers

Determine struct size, ignoring padding

I receive datagrams through a network and I would like to copy the data to a struct with the appropirate fields (corresponding to the format of the message). There are many different types of datagrams (with different fields and size). Here is a…
martinkunev
  • 1,364
  • 18
  • 39
-1
votes
1 answer

fgetc dropping characters when reading 2d pixel map with for loop

I am working on inputting a 2d pixel array from a PPM file with the one I am testing being of width and length 5. Also I am aware that in a ppm file that is rgb it has 3 color values not just one. I had forgotten that before I wrote this code, but…
-1
votes
1 answer

How to declare identifier with internal-linkage in block-scope without prior declaration of that identifier with some linkage being visible?

Consider this: #include static int b; int main() { { int b; { extern int b; b = 2; } } printf("%d", b); } Here by definition the identifier 'b' which is assigned the value 2…
AnArrayOfFunctions
  • 3,452
  • 2
  • 29
  • 66
-1
votes
2 answers

Can you modify a nested struct's value using a pointer to the containing struct?

I've got a question regarding the behavior of structs in C. Take the given structs as an example: typedef struct { char num1; char num2; } structa; typedef struct { structa innerstruct; char num3; char num4; } structb; I assume…
NotVeryMoe
  • 544
  • 5
  • 9
-1
votes
1 answer

Can you give examples for the tips I listed about c11 standard's calloc to help me to understand them?

When I reading references about calloc in calloc reference in cppreference ,I found the following tips which I didn't get. calloc is thread-safe: it behaves as though only accessing the memory locations visible through its argument, and not any…
waterd
  • 603
  • 1
  • 7
  • 23
-1
votes
1 answer

Compiling C code with g++: Invalid conversion

I'm compiling c code with g++ and running in some problems. after fixing designated initializers I'm left with this error: error: invalid conversion from 'void*' to '__u8*' This is my code: static inline void put_unaligned_le16(__u16 val, __u16…
tzippy
  • 6,458
  • 30
  • 82
  • 151
-1
votes
3 answers

Differences between certain standards of C and C++

Where can i see all differences between C++11 and C99? I think that C++98 and C++03 based on C89 / C90. Is there any differences between them? And what about C++11 and C99? Some features from C99 were added to C++11, but others not (like compound…
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
-2
votes
1 answer

Why I can't assign struct returned by a function to struct?

I wrote "lightweight" time library and I have struct and typedef like this: struct tmt { uint16_t year; uint8_t month; uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; uint8_t weekday; uint8_t is_dst;…
Kamil
  • 13,363
  • 24
  • 88
  • 183
-2
votes
2 answers

C Some headers include each other

I can't solve next problem: //foo.h #ifndef FOO_H_ #define FOO_H_ #include "BAR.h" #include "foos/foo_bazz.h" typedef struct { ... } FOO; // HERE I HAVE CALL `foo_baz(foo, bar);` void foo_bar(FOO *foo, BAR *bar); #endif /* FOO_H_…
MrZlo
  • 9
  • 3
-2
votes
1 answer

Is a conformant C11 implementation allowed to compile every function into an infinite loop?

While C++ has forward progress guarantees, I don't see any analogous rule in the C11 specification. Would a C11 compiler that emitted an infinite loop for every function conform to the C11 specification? Assume that it does all preprocessing / etc…
TLW
  • 1,373
  • 9
  • 22
-2
votes
2 answers

Is "return i++, i, i++;" undefined behaviour in C?

If I write like this : i = i++, i, i++; It is undefined behaviour in C language. But, If I write like this: return i++, i, i++; // Is it UB? Is it undefined behaviour? Example: #include int f(int i) { return i++, i, i++; // Is it…
msc
  • 33,420
  • 29
  • 119
  • 214