Skip to main content

All Questions

Tagged with
0 votes
1 answer
52 views

Expressing a pointer to a const function

In C, I can express a pointer to a const function like this: typedef void fun_t(void); const fun_t *fp; (I don't know if the type of fp has any practical use, but it is a real and distinct type; e.g.,...
Erik Carstensen's user avatar
0 votes
2 answers
113 views

Consolidating GNU C's and C23's deprecated function attribute

The problem I am facing when using the below macro // Assume that __GNUC__ or __clang__ is defined. #if defined(__has_c_attribute) #if __has_c_attribute(deprecated) #define ...
Harith's user avatar
  • 7,235
36 votes
2 answers
3k views

Why isn't the keyword false an integer constant expression in gcc C23?

Latest gcc 13.x (trunk) gives a compiler error (gcc -std=c23) for this code: int* p = false; error: incompatible types when initializing type 'int *' using type '_Bool' How can this be correct? C23 ...
Lundin's user avatar
  • 208k
2 votes
2 answers
184 views

Plain C equivalent to Rust's unimplemented!() macros

Please note that this is not a question on C++, but on plain C In Rust there is a handy macro unimplemented!() to let the runtime crash, to be used when a function is unimplemented. I basically have ...
wirrbel's user avatar
  • 3,261
7 votes
1 answer
200 views

Why doesn't gcc 13 display the correct binary represenation?

While answering a question here, I made the following example: #include <stdio.h> #include <math.h> int main (void) { float_t a = -248.75; printf("%f\n", a); unsigned ...
Lundin's user avatar
  • 208k
2 votes
2 answers
2k views

gcc: constexpr functions in C23?

Playing around with constexpr with GCC v14.0 (which should be close to the soon to be released GCC v13.1), I compiled the following module: constexpr int f (int x) { return x + 2; } constexpr ...
emacs drives me nuts's user avatar
0 votes
2 answers
474 views

Regarding mainstream compilers and int main(){} in C23

My program: int main(){} In upcoming C23, non-prototype and "K&R style" functions are removed. I realize that C23 is not yet formally released, but the current behavior of gcc and clang ...
Lundin's user avatar
  • 208k
3 votes
1 answer
1k views

Looking for stdckdint.h in the gcc 11.2 collection

I'm trying to find a copy of stdckdint.h, which I assume should be in the gcc 11.2 collection, but a search fails to locate it in the downloaded source tarball. Is it not public yet, or do I have to ...
Ian's user avatar
  • 1,657
3 votes
1 answer
503 views

Is [[nodiscard]] any different from [[gnu::warn_unused_result]]?

I had some code that used the GCC extension [[gnu::warn_unused_result]] (a.k.a. __attribute__((__warn_unused_result__))). Now I attempted to use C2x's [[nodiscard]] and I got an incomprehensible ...
alx - recommends codidact's user avatar