From b3e9e62599532050fc776c5e8f076915b56c2235 Mon Sep 17 00:00:00 2001 From: David Faulkner Date: Fri, 7 Aug 2026 23:40:47 -0500 Subject: Import official C23 code examples for Modern C (Jens Gustedt, 2024) - Add official C source files, Makefile, c23-fallback.h, and LICENSE - Update README.md with study mirror notice --- constexpr.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 constexpr.c (limited to 'constexpr.c') diff --git a/constexpr.c b/constexpr.c new file mode 100644 index 0000000..81bd929 --- /dev/null +++ b/constexpr.c @@ -0,0 +1,29 @@ +#include "c23-fallback.h" +#include +#include + +#if __is_identifier(constexpr) +# error "constexpr is needed for this test" +// really stop it +# include "really stop useless compilation right now" +#endif + + +#define eatit(P) printf("" #P ": %p\n", &(P)) + +[[__maybe_unused__]] static constexpr size_t size_max = (size_t)-1; + +[[__maybe_unused__]] constexpr long double π = 3.141'592'653'589'793'238'46; +[[__maybe_unused__]] constexpr long double π² = π*π; + +[[__maybe_unused__]] constexpr div_t one = { .quot = 1, .rem = 0, }; + +[[__maybe_unused__]] constexpr double E𝟏[2][2] = { {1, 0,}, {0, 1,}, }; + +int main(void) { + eatit(size_max); + eatit(π); + eatit(π²); + eatit(one); + eatit(E𝟏); +} -- cgit v1.2.3