c11

Can an implementation that has sizeof (int) == 1 “fully conform”? [duplicate]

吃可爱长大的小学妹 提交于 2021-02-16 06:13:36
问题 This question already has answers here : Can sizeof(int) ever be 1 on a hosted implementation? (8 answers) Closed 5 years ago . According to the C standard, any characters returned by fgetc are returned in the form of unsigned char values, "converted to an int " (that quote comes from the C standard, stating that there is indeed a conversion). When sizeof (int) == 1 , many unsigned char values are outside of range. It is thus possible that some of those unsigned char values might end up being

How can a macro define a valid global name based on the type passed to it?

守給你的承諾、 提交于 2021-02-10 04:36:05
问题 I believe the title is self-explanatory, but here's an example to illustrate what I'm trying to accomplish: #define PASTE2(_0, _1) _0 ## _1 #define DEFINE_OPS_FOR_TYPE(TYPE) \ int PASTE2(do_something_with_, TYPE)(void) { \ /* do_something_with_<TYPE> */ \ } Everything works fine for char , int , and single-worded types, but when it comes to unsigned types, or others that have multiple keywords, using token pasting ( a ## b ) does not generate a valid name due to the whitespace (e.g.: do

C4996, fopen deprecated: Why? (NOT: How to suppress) [closed]

坚强是说给别人听的谎言 提交于 2021-02-08 20:44:20
问题 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 . Improve this question What is unsafe with fopen that's more safe with fopen_s ? How can fopen be used in a safe way (if possible)? (I don't want to know how to suppress the warning - there are enough stackoverflow articles that answer that question) Edit: Question was closed

C4996, fopen deprecated: Why? (NOT: How to suppress) [closed]

狂风中的少年 提交于 2021-02-08 20:41:59
问题 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 . Improve this question What is unsafe with fopen that's more safe with fopen_s ? How can fopen be used in a safe way (if possible)? (I don't want to know how to suppress the warning - there are enough stackoverflow articles that answer that question) Edit: Question was closed

Why can't I “goto default;” or “goto case x;” within a switch selection structure?

会有一股神秘感。 提交于 2021-02-07 11:22:49
问题 Section 6.8.1 of C11 or C99, or section 3.6.1 of C89 all seem to indicate that default and case x (where x is some constant-expression ) are examples of labeled statements, along-side identifier: -style labels that are suitable for use with goto . I'm aware that I could simply place an identifier: -style label directly following the default: or case x: labels. That's not what this question is about. I'm more curious as to whether there is any actual rationale behind prohibiting this kind of

Why can't I “goto default;” or “goto case x;” within a switch selection structure?

醉酒当歌 提交于 2021-02-07 11:22:38
问题 Section 6.8.1 of C11 or C99, or section 3.6.1 of C89 all seem to indicate that default and case x (where x is some constant-expression ) are examples of labeled statements, along-side identifier: -style labels that are suitable for use with goto . I'm aware that I could simply place an identifier: -style label directly following the default: or case x: labels. That's not what this question is about. I'm more curious as to whether there is any actual rationale behind prohibiting this kind of

Why can't I “goto default;” or “goto case x;” within a switch selection structure?

ぐ巨炮叔叔 提交于 2021-02-07 11:22:32
问题 Section 6.8.1 of C11 or C99, or section 3.6.1 of C89 all seem to indicate that default and case x (where x is some constant-expression ) are examples of labeled statements, along-side identifier: -style labels that are suitable for use with goto . I'm aware that I could simply place an identifier: -style label directly following the default: or case x: labels. That's not what this question is about. I'm more curious as to whether there is any actual rationale behind prohibiting this kind of

Using void pointer to simulate a generic linkedlist in C

ぃ、小莉子 提交于 2021-01-28 13:04:09
问题 I'm new to C, and I think there may be an issue with pointers here. Any help would be appreciated! I have a linkedlist struct that looks like this: ll.h: #ifndef LLTEST_LL_H #define LLTEST_LL_H #include <stdlib.h> typedef struct _listNode { void *data; struct _listNode *next; } listNode; typedef struct { int logicalLength; int elementSize; listNode *head; listNode *tail; } linkedlist; typedef struct table { const char* name; size_t col_count; size_t length; } table; typedef struct db { const

What are the semantics of function pointers with empty parentheses in each C standard?

佐手、 提交于 2021-01-28 08:22:28
问题 Answers to this and this question say that function pointers of the form return-type (*pointer)() are pointers to a function which takes any number of arguments, though the latter says they obsolesced in C11. On an i386 system with GCC, “extra” arguments passed in a call to an empty-parentheses-type’d function pointer are ignored, because of how stack frames work; e.g., /* test.c */ #include <stdio.h> int foo(int arg) { return arg; } int main(void) { int (*fp)() = foo; printf("%d\n", fp

uchar.h file not found on OS X 10.9

一世执手 提交于 2020-12-29 03:04:43
问题 I'm under the impression my C compiler supports C11 since it accepts the -std=c11 flag, $ cc --version Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.3.0 Thread model: posix and uchar.h is part of the C11 standard, so I'd expect this program to compile, $ cat /tmp/esc.c #include <uchar.h> int main(void) {} But $ cc /tmp/esc.c /tmp/esc.c:1:10: fatal error: 'uchar.h' file not found #include <uchar.h> ^ 1 error generated. I tried locating the uchar.h