>> reference count ... copies ... only then is StringB copied
>You're right I should - and will - use this. But note it won't cover cases where the user modifies/copies the string from outside the API. The lib won't be aware.
But that's perfectly OK! Just explain any and all caveats/gotchas/potential issues -- to the end-user in the docs, and they'll understand and work around them! Most programmers are smart people, and they'll be totally OK with it if you explain those things to them in the docs!
>> no nested macros
>I hear you. I thought it made them more readable.
The macros DO make the code more readable(!) -- at least the non-nested ones!
The nested ones are kind of OK, and yes, they kind of make the code more readable -- but in exchange for this readability, you're getting farther and farther away from the underlying generated C code!
That's OK to a point -- but I've seen codebases where they've went N levels (not 1, not 2, but multiple, multiple) levels deep on the macros -- and what was gained in early macro readability -- gets lost in massively recursive macro hierarchies!
For your future sanity, try to avoid going in that direction!
Like, maybe set a limit of no more than two, two being the absolute maximum, and only if you really really need to do it -- levels of macros...
Because the temptation is going to be (at least in the future!) -- to use even more levels of macros!
That'll work great for a while (it's a double-edged sword!)... but at some point, a deeply nested structure can really, and I mean really bite you in the butt -- with hard-to-find bugs and anomalies, when you least expect it, and when you most need it to work!
But again, all of this being said, "I am not the market".
You might find that 1,000,000 plus C programmers -- absolutely love what you've done with the nested macros, and if so, I say "go with it!" (at least, if appealing to a broad base is your goal, and the broad base wants things done that way!)
But, all of this being said, you choose an excellent problem to solve, and you put in an excellent effort, and I applaud your work!