3 ms·
Root problem is the lack of namespaces in C, making collisions inevitable and painful to deal with
by zokier 4y ago
Root problem is the lack of namespaces in C, making collisions inevitable and painful to deal with
- flohofwoe 4y agoC doesn't even need namespaces for this, a simple stdc_ prefix for stdlib functions and types would also work (see C23 stdbit.h, I hope this won't be an outlier).
- im3w1l 4y agoWith proper namespaces you can import stuff so you don't have to prefix with the namespace every time.
- flohofwoe 4y agoYes, but we can't simply port C++ namespaces over because this requires symbol name mangling. C could be using 'namespace prefixes' instead with something like 'usingprefix stdc_', this wouldn't require changes to the symbol format, and would provide most of the features of C++ namespaces.
- int_19h 4y agoThat gets very ugly very quick for something as basic as e.g. memcpy or strcmp.
- kevin_thibedeau 4y agoC23 technically has to support namespaces for attributes. It'll be interesting to see if they get adopted into the core language at some point.