3 ms·
C doesn't have namespaces. The only sane way to deal with name collisions is either to use C stdlib types in library APIs (e.g. uint8_t), or use a library spec
by flohofwoe 3y ago
C doesn't have namespaces.
The only sane way to deal with name collisions is either to use C stdlib types in library APIs (e.g. uint8_t), or use a library specific prefix (e.g. mylib_u8) - which is of course even more awkward than just using the standard uint8_t.
- naasking 3y agoA prefix and a namespace aren't really that different in practice.
- staunton 3y agoThey are different. Namespaces are syntactically enforced and you can opt-in or out to names. To have syntactically validated qualified access. Naming might go well and have the same utility, but you never know what evil things are going on in all those headers, redefining each other's symbols and yours.
- naasking 3y agoYou seem to be focusing on specific problems with C/C++. I don't really care about that, all I'm saying is that prefixing names are equivalent to placing them within a namespace, in practice, and theoretically come to think of it. You can easily define a bijection between namespaced symbols and prefixed symbols. Requiring the full prefixes are simply a tad more verbose, essentially equivalent to using a fully qualified name for symbol.
- sieabahlpark 3y ago[dead]