when you're done, you'd have learnt enough on the way and know what you don't know
445 karma · joined February 24, 2020
when you're done, you'd have learnt enough on the way and know what you don't know
_If, _Ifdef, _Ifndef
inside function macrosfor example:
#ifdef SOME_CONST
#define WHATEVER(w, h, a, t, e, v, e, r) \
... common part ... \
... for SOME_CONST ... \
... common part continued ...
#else
#define WHATEVER(w, h, a, t, e, v, e, r) \
... common part ... \
... when SOME_CONST not defined ... \
... common part continued ...
#endif
With _Ifdef, the above could be written like: #define WHATEVER(w, h, a, t, e, v, e, r) \
... common part ... \
_Ifdef(SOME_CONST, \
(... for SOME_CONST ...) , \
(... when SOME_CONST is not defined ...)
) \
... common part continued ...
With these, one could also do: #define FACTORIAL(n) _If(n == 0, 1, (n) * FACTORIAL(n))
int f = FACTORIAL(6);
turns into:
int f = (6) * (5) * (4) * (3) * (2) * (1) * 1;That would be very useful, I think. It might help with code duplication in function macros.
Maybe _Switch/_Case thereafter.
If OSes do that, why not standardize that in C?
If there exists any memory block allocated using malloc() / calloc() / realloc() which has not been free()'d, at the end of the program, they would be free()'d automatically.
One can easily do it with keeping a linked list and using atexit(), but, can it be added to the standard?
A general question, will anything, any feature, which is "easy" to implement in pure C, like array knowing its own length or pascal strings, NOT be allowed to be in C standard, even if it is widely used, maybe almost everywhere?
how many people [have] read t&c and privacy policy?