On 2015-04-27 6:29 AM, Neil wrote:
NS_LITERAL_STRING, as its name suggests, only ever gets used on string
literals, or macros that expand to string literals.

NS_LITERAL_CSTRING gets (ab?)used in all sorts of ways. Should we be
consistent and require NS_LITERAL_CSTRING to be used on string literals?

I would say yes.

I found the following in-tree examples, none of which would have worked
with NS_LITERAL_STRING:

These are terrible!

When I tried enforcing string literals the compilers also tripped up
over this line but it might be because of the way macros are expanded:
nsCString f008 = NS_LITERAL_CSTRING(__FUNCTION__);

That's because __FUNCTION__ doesn't get handled by the preprocessor! The compilers typically cannot replace it with a string sooner than the semantic analysis phase since they need to, well, know what function it's used in. :-)
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to