3 ms·
What you're talking about typically goes by the name of "pascal strings", and while they're possible to do, C's string literals are not compatible with them, so
by ninkendo 7y ago
What you're talking about typically goes by the name of "pascal strings", and while they're possible to do, C's string literals are not compatible with them, so nobody does it.
- tyingq 7y agosds (simple dynamic strings) is a decent compromise: https://github.com/antirez/sds https://github.com/antirez/sds (used in redis)
- childintime 7y agoIt is certainly possible to declare Pascal string literals with not much hassle: https://stackoverflow.com/questions/7648947/declaring-pascal-style-strings-in-c https://stackoverflow.com/questions/7648947/declaring-pascal... One of the answers states that GCC and Clang do have support for Pascal strings. Probably these strings do not work as (well) in #defines, i.e. they don't concat like regular literals.