[email protected] wrote in
<[email protected]>:
|Sam Ellicott <[email protected]> wrote:
|
|> What *exact* parts of C11 is tcc missing that makes compilation fail.
|>
|> * _Noreturn - not really useful for tcc, but just "absorbing" it wouldn't
|> cause problems and be easy to implement
|> * _Static_assert - This might be painful to implement, or it might \
|> be easy.
|> I don't know.
|
|GNU grep and GNULIB use at least those two, with workarounds if
|they're not supported, or in the case of gawk, removing static assert
|and using older versions of the file.
|
|One data point, for whatever it's worth.
To mention that ISO C _Static_assert is absolutely unusable before
ISO C23. I am not with standard-affine language (especially not
ISO and further C, but a now member of ISO C said to me after not
having believed my very claim), .. the following is a bit lengthy,
his final conclusion is
Ahhh, now I see what your problem was. The problem wasn't
static_assert(3) in C. The problem was that integer constant
expressions were significantly more strict in C11, and C23 has allowed
compilers to turn some code into constant expressions in certain cases.
I guess this is another good reason to use C23.
I say Ciao! already here.
...
|Things I find essential from modern dialects include static_assert(3),
And that was just unusable from ISO C when it came, for example.
It was a brainfart. They should simply have taken the exact
variant that C++ had introduced, at first.
...
I don't know how it was in C++ originally, but from what I can see in
cppreference, it was added in C++11, and it had the same form that it
has in C11. Essentially, it behaves as if:
void static_assert(bool constant_expression, const char *msg);
(Except that you can use it in file scope, and a few other places
where you couldn't use an expression.)
How was it unusable?
...
Pfff, in so far:
/* ISO C variant unusable pre-C23! */
#elif (!su_C_LANG && __cplusplus +0 >= 201103l) || \
(su_C_LANG && defined __STDC_VERSION__ && __STDC_VERSION__ +0 >=
202311l)
# define su_CTA(T,M) static_assert(T, M)
# define su_LCTA(T,M) static_assert(T, M)
#else
Sorry but this is all i know. I tried it, and it bailed.
Ah wait, i meant _Static_assert(), which was ISO C in 2011, and
that was completely unusable. They should have used the C++
static_assert() right away.
...
Did you forget to include <assert.h>?
> Ah wait, i meant _Static_assert(), which was ISO C in 2011, and
> that was completely unusable.
Apart from the name, it's functionally identical to static_assert(3).
_Static_assert(3) is a keyword, and static_assert(3) was a macro in C11,
provided by <assert.h>. In C23, static_assert(3) became a keyword too.
> They should have used the C++
> static_assert() right away.
You mean the name? You could include <assert.h> and get the C++ name.
Here are the relevant contents of the manual page. I'm really surprised
to hear that you can't use it until C23.
...
No no, it was broken. It could not evaluate the same expressions
as the C++ variant could. Maybe it was a compiler error, then.
Note the IANA TZ project also did it like so:
* private.h (static_assert): New macro, defined for pre-C23 compilers.
(SIGNED_PADDING_CHECK_NEEDED): New constant.
Try to check that TIME_T_MIN and TIME_T_MAX are actually the min and
max time_t values.
..
+#if __STDC_VERSION__ < 202311
+# define static_assert(cond) extern int static_assert_check[(cond) ? 1 :
-1]
+#endif
(I am now not reading exact ISO C definitions to find reasons why
the C11 variant was borked. But it was once i tested.)
...
Ahhh, now I see what your problem was. The problem wasn't
static_assert(3) in C. The problem was that integer constant
expressions were significantly more strict in C11, and C23 has allowed
compilers to turn some code into constant expressions in certain cases.
I guess this is another good reason to use C23.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel