c11

Standard way in C11 and C++11 to convert UTF-8?

Deadly 提交于 2019-12-04 00:21:00
C11 and C++11 both introduce the uchar.h / cuchar header defining char16_t and char32_t as explicitly 16 and 32 bit wide characters, added literal syntax u"" and U"" for writing strings with these character types, along with macros __STDC_UTF_16__ and __STDC_UTF_32__ that tell you whether or not they correspond to UTF-16 and UTF-32 code units. This helps remove the ambiguity about wchar_t , which on some platforms was 16 bit and generally used to hold UTF-16 code units, and on some platforms was 32 bit and generally used to hold UTF-32 code units; assuming those macros are now set, you can now

Are there any implementations that support a negative zero, or reserve it as a trap representation?

天涯浪子 提交于 2019-12-03 20:48:51
On most implementations of this day and age, a signed integer value that has a bit pattern of 1 for the sign bit and all 0 for the value bits tends to represent the lowest possible value for that signed integer type. However, as 6.2.6.2p2 states, that's not a requirement: Which of these applies is implementation-defined, as is whether the value with sign bit 1 and all value bits zero (for the first two), or with sign bit and all value bits 1 (for ones' complement), is a trap representation or a normal value. My first question is simple: Are there any implementations that use this bit pattern

Does ctype.h still require unsigned char?

孤人 提交于 2019-12-03 18:03:18
问题 Traditionally, it was - strictly speaking - an error to pass a signed char to the ctype.h predicates because they were only defined for -1 to 255, so -128 to -2 could end up in reading outside array bounds. Was this ever fixed, or do you still strictly speaking have to use unsigned char to avoid undefined behaviour in modern versions of C? 回答1: do you still strictly speaking have to use unsigned char to avoid undefined behavior in modern versions of C? Yes, from the C11 draft standard section

C11 anonymous structs via typedefs?

爱⌒轻易说出口 提交于 2019-12-03 15:50:21
问题 Anonymous structs have been added in the C11 standard, so typedef struct { struct {int a, b}; int c; } abc_struct; is valid and standard. Is it also within the standard to use a typedef in place of the full struct declaration? E.g.: typedef struct { int a, b; } ab_struct; typedef struct { ab_struct; int c; } abc_struct; The GCC documentation says that this is a Plan 9 extension, but then it works in the few compilers I've tried (including GCC...). By my reading of the standard itself, I think

Why can I use gets() in gcc -std=c11?

妖精的绣舞 提交于 2019-12-03 12:24:52
The gets() function has been removed from the C language. No such function exists in the standard. Yet I compile the following code: #include <stdio.h> int main (void) { (void) gets (NULL); } using gcc -std=c11 -pedantic-errors -Wall -Wextra and it compiles without giving any errors or warnings. Similarly, #include <stdio.h> int gets; int main (void) {} will not compile (error: 'gets' redeclared as different kind of symbol). In the standard 4. Conformance §6 we can read: A conforming implementation may have extensions (including additional library functions), provided they do not alter the

C1x: When will it land, what to expect?

廉价感情. 提交于 2019-12-03 10:21:45
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 to feed on one another's improvements, will C be feeding on the C++1x standard? What can I look forward to in C's future? Jukka Suomela The ISO/IEC 9899:2011 standard , aka C11, was published in December 2011 . The latest draft is N1570 ; I'm not aware of any differences between it and the final standard. There's already a Technical Corrigendum

cocos2d-x工程中,让xcode4.6能够使用C++11标准库

冷暖自知 提交于 2019-12-03 10:21:23
在Cocos2d-x的开发中,如果你使用的xcode4.6,有时候希望使用C++11标准库的东西,比如 std::array,如果直接, # include <array> 将会出现无法找到array的问题。 这个时候我们就要对我们的xcode进行一下简单的配置。 在Building Settings里面,首先点击All, 然后在"Apple LLVM Compiler 4.2 - Language"区域: 设置 "C++ Language Dialect" 选项为 "c11" 设置 "C++ Standard Library" 选项为 "libc++ (LLVM standard C++ library with C++11 support)" 更多详细,请参见screenshot. 引用自stackoverflow Howard Hinnant's answer (with corrections) is the correct answer for the command line. To use the new C++11 standard library inside of Xcode: In the Build Settings tab for your project, scroll down to "Apple LLVM Compiler 4.1 >-

Lifetime of temporary objects in C11 vs C99

主宰稳场 提交于 2019-12-03 10:05:11
I am trying to decipher a note that led to a change between C99 and C11. The change proposed in that note ended up in C11's 6.2.4:8, namely: A non-lvalue expression with structure or union type, where the structure or union contains a member with array type (including, recursively, members of all contained structures and unions) refers to an object with automatic storage duration and temporary lifetime. Its lifetime begins when the expression is evaluated and its initial value is the value of the expression. Its lifetime ends when the evaluation of the containing full expression or full

Do I need -pedantic flag from GCC with C11?

大兔子大兔子 提交于 2019-12-03 08:39:37
I'm currently running Linux Mint on my Machine with GCC-5.3 because C11 is included default. I started learning C for myself just for fun and at that time the GCC version was 4.8 if I remember right. Any way if one use GCC-4.8 with -pedantic flag on the following program: #include <stdio.h> #include <string.h> int main(void){ char *arr =

Are these compatible function types in C?

安稳与你 提交于 2019-12-03 04:45:59
问题 Consider the following C program: int f() { return 9; } int main() { int (*h1)(int); h1 = f; // why is this allowed? return h1(7); } According to the C11 Standard, Sec. 6.5.16.1, in a simple assignment, "one of the following shall hold", and the only relevant one in the list is the following: the left operand has atomic, qualified, or unqualified pointer type, and (considering the type the left operand would have after lvalue conversion) both operands are pointers to qualified or unqualified