c11

Glibc - error in ucontext.h, but only with -std=c11

自古美人都是妖i 提交于 2019-12-11 11:33:41
问题 I have this minimal helloworld, extended with an include of ucontext.h : #include <ucontext.h> #include <stdio.h> int main(int argc, char** argv) { printf ("hello world!\n"); return 0; } It compiles without warning with gcc-4.9 ( gcc -c hw.c -Wall ). But if I switch to the c11 standard ( gcc -std=c11 -c hw.c -Wall ), I get the following error: $ gcc -std=c11 -c hw.c -Wall In file included from /usr/include/ucontext.h:26:0, from hw.c:1: /usr/include/x86_64-linux-gnu/sys/ucontext.h:137:5: error

Does the implementation of strtoul in glibc conflicts with the C11 standard?

岁酱吖の 提交于 2019-12-11 09:50:50
问题 The follows is the description of function strtoul in stdlib.h implemented by glibc: Function: unsigned long int strtoul (const char *retrict string, char **restrict tailptr, int base) Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | See POSIX Safety Concepts. The strtoul (“string-to-unsigned-long”) function is like strtol except it converts to an unsigned long int value. The syntax is the same as described above for strtol. The value returned on overflow is ULONG_MAX (see Range of Type).

snprintf: Are there any C Standard Proposals/plans to change the description of this func?

允我心安 提交于 2019-12-11 08:53:49
问题 Are there any Proposals (or plans) to the C language Standard to change the (last sentence of the) description of the snprintf function such that the ambiguity described in this my answer to the question - "Is snprintf() ALWAYS null terminating?"- is resolved? (Or how (using which links) can I determine by myself if there are any such Proposals? Is there any search engine that can show all the currently active Proposals about the snprintf function? The only link I currently know is this one -

What does assignment mean to a C11 atomic?

感情迁移 提交于 2019-12-11 08:03:59
问题 For example, atomic_int test(void) { atomic_int tmp = ATOMIC_VAR_INIT(14); tmp = 47; // Looks like atomic_store atomic_int mc; // Probably just uninitialised data memcpy(&mc,&tmp,sizeof(mc)); // Probably equivalent to a copy tmp = mc + 4; // Arithmetic return tmp; // A copy - perhaps load then store } Clang is happy with all this. I've read section 7.17 of the standard, and it says a lot about the memory model and the defined functions (init, store, load etc) but doesn't say anything about

C - Cannot access memory at address

佐手、 提交于 2019-12-11 06:43:56
问题 When debugging GDB tells me the following error: 0x800c99ed00000001 < error: Cannot access memory at address 0x800c99ed00000001> The error is produced if I put a breakpoint when I call ConvertByteArrayToFloat while debugging . But the program exits without a problem and gives me an Ok result ? My main file: #include "Local.h" int main(void) { if(HandleReceivedMessages() == OP_COMPLETED){ printf("Main Completed \n" ); } else { printf("Main Failed \n"); } return 0; } Local.h #ifndef LOCAL_H_

Memory order consume usage in C11

旧时模样 提交于 2019-12-10 23:45:57
问题 I read about the carries a dependency relation and dependency-ordered before that uses one in its definition 5.1.2.4(p16) : An evaluation A is dependency-ordered before an evaluation B if: — A performs a release operation on an atomic object M , and, in another thread, B performs a consume operation on M and reads a value written by any side effect in the release sequence headed by A , or — for some evaluation X , A is dependency-ordered before X and X carries a dependency to B . So I tried

Initializing objects with macros for integer constants

隐身守侯 提交于 2019-12-10 20:56:57
问题 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf 7.20.4 introduces Macro integer constants with: 1 The following function-like macros expand to integer constants suitable for initializing objects that have integer types corresponding to types defined in <stdint.h>. Each macro name corresponds to a similar type name in 7.20.1.2 or 7.20.1.5. I don't quite understand this paragraph. The macros basically slap the appropriate suffix onto an unsuffixed number as in: UINT64_C(0x123) =>

_Noreturn in a struct in c: error: expected specifier-qualifier-list before '_Noreturn'

﹥>﹥吖頭↗ 提交于 2019-12-10 17:27:56
问题 I am trying to compile a piece of code that contains _Noreturn: #ifndef SOMEHEADER_H #define SOMEHEADER_H #include <stdalign.h> #include <stdbool.h> #include <stdint.h> extern struct s { _Noreturn void (*somenoreturnfunc)(bool); } svar; #endif Which gives me: error: expected specifier-qualifier-list before '_Noreturn' on: _Noreturn void (*somenoreturnfunc)(bool); So I tried the suggestion from here: #ifndef SOMEHEADER_H #define SOMEHEADER_H #include <stdalign.h> #include <stdbool.h> #include

Is there a recommended integer type to store function pointers in standard C

a 夏天 提交于 2019-12-10 16:57:42
问题 The C99 standard has uintptr_t , a recommended integer type to convert data pointers (pointers to objects) to, but I did not find an equivalent integer type to store function pointers. Did I overlook it? A specific compiler could define such a type even though it is not in the standard, but a compiler is more likely to state that a function pointer can be stored in (say) a uint64_t than to define a new type. Another difference is that it can make sense to do integer arithmetic on a data

When will the safe string functions of C11 be part of glibc? [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 15:56:17
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . The C11 standard Annex K defines a bunch of new safer string functions, all suffixed by _s (e.g. strcpy_s ). Do you know when these new functions will become available in the GNU C library glibc? So far you have to fall back to a third party library like safec. 回答1: Do you