Questions tagged [c17]

C17 is the informal name of the current standard (ISO/IEC 9899:2018) of the C programming language. It replaces C11, but introduces no new features. Instead the focus of C17 has been to resolve defect reports (DRs).

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 the current standard, this complement should be the tag. Please see the tag for details.

Detection

A standard macro __STDC_VERSION__ is defined with the value 201710L to indicate that C17 support is available.

More Info:

64 questions
1
vote
4 answers

What is the rationale for "semantics violation does not require diagnostics"?

Follow-up question for: If "shall / shall not" requirement is violated, then does it matter in which section (e.g. Semantics, Constraints) such requirement is located?. ISO/IEC 9899:202x (E) working draft— December 11, 2020 N2596, 5.1.1.3…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
4 answers

Is there such a thing as nullptr (or equivalent) in modern C standards?

I included a check for nullptr in a line of C code. The compiler (gcc) complained when using -std=c17 as well as -std=gnu17. Is there such a thing as nullptr (or equivalent) in modern C standards? (C11, C17) If not, then why?
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
1
vote
2 answers

Does "strictly conforming program" + no extensions mean "no diagnostics emitted"?

Follow-up question for: clang: + leads to confusing warning: adding 'int' to a string does not append to the string. Does "strictly conforming program" + no extensions mean "no diagnostics…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
3 answers

Which C rules allow to use in function declarator an identifier, which was previously defined as a type?

Consider this code (t0.c): typedef int T; void f(int T); Invocations: gcc -std=c11 -Wall -Wextra -pedantic -c t0.c clang -std=c11 -Wall -Wextra -pedantic -c t0.c cl /std:c11 /Za /c t0.c t0.c(2): warning C4224: nonstandard…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
1 answer

printf("%a"): how the format and parameters of hexadecimal floating-point constant are selected?

Consider this simple code (t0.c): #include #include #if DBL_HAS_SUBNORM == 1 double d = 0x23d804860c09bp-1119; int main(void) { printf("%a\n", d); return 0; } #endif Invocation and output: # host: CPU: Intel, OS:…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
1 answer

Is there a standard way to check at compile time that file is being preprocessed only?

Context: all the compilers except __MY_CC__ are not supported. However, how to permit only preprocessing with a 3rd-party compiler? #if cc -E /* permit only preprocessing with a 3rd-party compiler */ #elif ! __MY_CC__ #error unsupported…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
2 answers

Is there a standard way to guarantee that a certain (constant) expressions will be evaluated at compile (translation) time?

I am quite surprised that C does not guarantee that certain (constant) expressions are evaluated at compile (translation) time. C11 (6.6 Constant expressions) (emphasis added): A constant expression can be evaluated during translation rather than…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
1 answer

Why Clang running on Windows has no C conformance (__STDC__ is not defined to 1)?

Sample code (t127.c): #include int main(void) { int ret; #if __STDC__ == 1 printf("Has C conformance to version "); #if __STDC_VERSION__ printf("%ld", __STDC_VERSION__); #else printf("1989"); #endif printf(" OR has no…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
1 answer

Why QNAN == QNAN does not lead to raising FE_INVALID exception?

Code (t125.c): #include #include #include #if _MSC_VER #pragma fenv_access (on) #else #pragma STDC FENV_ACCESS ON #endif void show_fe_exceptions(void) { printf("exceptions raised: "); if…
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
2 answers

Can I treat an `enum` variable as an `int` in C17?

TL;DR: Is it right to assume, given enum NAME {...};, that enum NAME n is the same as int n during execution? Can n be operated on as if it were a signed int, even though it is declared as enum NAME? The reason: I really want to use enum types for…
1
vote
1 answer

Is assignment x=1; always an undefined behaviour according to C17?

I'm looking at the final draft of C17, N2176. Here, I'm concerned with what kind of expression with side effects would have it's behaviour undefined. In section 6.5 Expressions of the standard, there is paragraph 2 that starts with: If a side…
lpetru
  • 117
  • 5
1
vote
3 answers

Will C++20 standard include C18 standard

I tried to google and quick search on latest draft for "C lang" and "C18" on openstd org. Will C++ standard support the latest standards of C?
0
votes
0 answers

Different size assigned to multiple variables which are declared continually in one statement

Trying to figure out why continued declaration is not a good Idea I suddenly realized the size assigned to following variables are not the same: char const* const ALPHA, BETA; printf("sizeof(ALPHA): %lu\n", sizeof(ALPHA)); printf("sizeof(BETA):…
void
  • 7,760
  • 3
  • 25
  • 43
0
votes
1 answer

How to correctly downcast in C?

I'm currently limited to coding in C and I want to do C object oriented programming. One thing that comes to mind is how to correctly downcast a type in C without violating strict aliasing. Imagine I have an animal struct with a vtable (meaning a…
Alexander Oh
  • 24,223
  • 14
  • 73
  • 76
0
votes
0 answers

Why don't tentative definitions cause errors due to multiple definitions?

The C17 standard says that If a translation unit contains one or more tentative definitions for an identifier, and the translation unit contains no external definition for that identifier, then the behavior is exactly as if the translation unit…
vbyzjnlehi
  • 307
  • 2
  • 15