c11

Are there any plans for a future C standard after C11?

旧街凉风 提交于 2019-12-03 03:01:23
问题 I searched on the open standards website, particularly the C working group homepage but only found information about C11. They seem to have regular meetings and discuss different features and extensions, but they never actually mention a future C standard nor roadmap. It is hard to tell whether they are working on a new standard or just a Technical Corrigendum to the current standard. 回答1: I sent an email to the guy on the WG 14 contact section but I didn't expect to get an answer anytime

What is a composite type in C?

六眼飞鱼酱① 提交于 2019-12-03 02:46:15
From §6.2.7.5 (page 66): EXAMPLE Given the following two file scope declarations: int f(int (*)(), double (*)[3]); int f(int (*)(char *), double (*)[]); The resulting composite type for the function is: int f(int (*)(char *), double (*)[3]); Above the example, they explain that a composite type is a type, compatible with two different types. I would intuitively understand the phrase "composite type" as meaning "structures and unions", which appears to be way off-target. What is a composite type in C and what is it used for? Could someone please explain the example above in details? I would

Printing null pointers with %p is undefined behavior?

痞子三分冷 提交于 2019-12-03 02:32:40
问题 Is it undefined behavior to print null pointers with the %p conversion specifier? #include <stdio.h> int main(void) { void *p = NULL; printf("%p", p); return 0; } The question applies to the C standard, and not to C implementations. 回答1: This is one of those weird corner cases where we're subject to the limitations of the English language and inconsistent structure in the standard. So at best, I can make a compelling counter-argument, as it's impossible to prove it :) 1 The code in the

What is C17 and what changes have been made to the language?

ε祈祈猫儿з 提交于 2019-12-03 01:52:04
问题 As I was checking news about GCC 8, I saw that they added support for the 2017 version of the C language (not C++17, really C17). But I can't find any information about it on Internet. Is it a new ISO version like C11, or just a codename used by the GCC team for some corrections in their compiler ? 回答1: According to GCC reference, C17 is actually a bug-fix version of the C11 standard with DR resolutions integrated. C17 , a bug-fix version of the C11 standard with DR resolutions integrated ,

Why does “sizeof(a ? true : false)” give an output of four bytes?

帅比萌擦擦* 提交于 2019-12-03 01:23:43
问题 I have a small piece of code about the sizeof operator with the ternary operator: #include <stdio.h> #include <stdbool.h> int main() { bool a = true; printf("%zu\n", sizeof(bool)); // Ok printf("%zu\n", sizeof(a)); // Ok printf("%zu\n", sizeof(a ? true : false)); // Why 4? return 0; } Output (GCC): 1 1 4 // Why 4? But here, printf("%zu\n", sizeof(a ? true : false)); // Why 4? the ternary operator returns boolean type and sizeof bool type is 1 byte in C. Then why does sizeof(a ? true : false)

C11 Standard docs

♀尐吖头ヾ 提交于 2019-12-02 21:02:55
Starting from this SO protected question I'm trying to understand what the difference between those documents: 9899 2012 costs $60 9899 2011 costs $265 As you can see those documents have very different prices and I don't know if the cheaper one is valid or is something like draft or cut copy of the real standard. Did someone buy the INCITS one? EDIT As @Chqrlie pointed out: What is the difference between the ANSI and ISO official documents available for a free and the final draft freely accessible from the official website at open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf LPs I finally got

Are there any plans for a future C standard after C11?

北战南征 提交于 2019-12-02 16:34:25
I searched on the open standards website , particularly the C working group homepage but only found information about C11. They seem to have regular meetings and discuss different features and extensions, but they never actually mention a future C standard nor roadmap. It is hard to tell whether they are working on a new standard or just a Technical Corrigendum to the current standard. I sent an email to the guy on the WG 14 contact section but I didn't expect to get an answer anytime soon, however, I did. This is what he replied to me: the Committee has not discussed starting work on a new

Printing null pointers with %p is undefined behavior?

纵然是瞬间 提交于 2019-12-02 16:02:32
Is it undefined behavior to print null pointers with the %p conversion specifier? #include <stdio.h> int main(void) { void *p = NULL; printf("%p", p); return 0; } The question applies to the C standard, and not to C implementations. This is one of those weird corner cases where we're subject to the limitations of the English language and inconsistent structure in the standard. So at best, I can make a compelling counter-argument, as it's impossible to prove it :) 1 The code in the question exhibits well-defined behaviour. As [7.1.4] is the basis of the question, let's start there: Each of the

Why does “sizeof(a ? true : false)” give an output of four bytes?

岁酱吖の 提交于 2019-12-02 14:46:16
I have a small piece of code about the sizeof operator with the ternary operator: #include <stdio.h> #include <stdbool.h> int main() { bool a = true; printf("%zu\n", sizeof(bool)); // Ok printf("%zu\n", sizeof(a)); // Ok printf("%zu\n", sizeof(a ? true : false)); // Why 4? return 0; } Output ( GCC ): 1 1 4 // Why 4? But here, printf("%zu\n", sizeof(a ? true : false)); // Why 4? the ternary operator returns boolean type and sizeof bool type is 1 byte in C. Then why does sizeof(a ? true : false) give an output of four bytes? It's because you have #include <stdbool.h> . That header defines macros

Compile time check against multiple types in C?

妖精的绣舞 提交于 2019-12-02 10:37:23
问题 Currently I have a macro to check a value is a type. #define CHECK_TYPE_INLINE(val, type) \ ((void)(((type)0) != (0 ? (val) : ((type)0)))) This is useful to be able to type-check macro args in some cases. But what if I were to check against multiple types? for example, to check if it's a struct Foo * or struct Bar * . Example, static inline _insert_item(struct List *ls, void *item) { /* function body*/ } /* type-checked wrapper */ #define insert_item(ls, item) \ (CHECK_TYPE_ANY(item, struct