Use standard unicode string literals with VS2015

RESOLVED FIXED in mozilla38

Status

()

defect
RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: briansmith, Assigned: briansmith)

Tracking

Trunk
mozilla38
x86_64
Windows 8.1
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

VS2015 won't conpile mfbt/char16.h without this change.

One thing I did not explore: Is MOZ_USE_CHAR16_WRAPPER still needed?
Attachment #8545588 - Flags: review?(jwalden+bmo)
(In reply to Brian Smith (:briansmith, :bsmith, use NEEDINFO?) from comment #0)
> One thing I did not explore: Is MOZ_USE_CHAR16_WRAPPER still needed?

That was added to support MingW compilation, since we historically used PRUnichar (now char16_t) and wchar_t more or less interchangeably on Windows. Given that Windows uses a lot of UTF-16-based APIs, I wasn't (and still am not) sure if they would add some extra variants or compiler magic when they eventually update the SDK. If a newer SDK adds char16_t* overloads, then it would probably be possible to get rid of it. If it doesn't happen, then it probably won't.
Comment on attachment 8545588 [details] [diff] [review]
vs2015-unicode-literals.patch

Review of attachment 8545588 [details] [diff] [review]:
-----------------------------------------------------------------

Yeah, unless Microsoft did something special to allow Windows APIs to accept char16_t stuff (seems unlikely, but maybe they'll do it someday), the wrapper things are going to have to keep living.

::: mfbt/Char16.h
@@ +17,5 @@
>   * is a 16-bit code unit of a Unicode code point, not a "character".
>   */
>  
>  #ifdef _MSC_VER
> +#if _MSC_VER < 1900

Undefined macros expand to 0, so you can do

#if defined(_MSC_VER) && _MSC_VER < 1900

here.  (Technically not even the defined() is needed, then, but I'd rather see it for clarity.)  Otherwise you'd have to indent these macro uses two spaces:

#ifdef _MSC_VER
#  if _MSC_VER < 1900
    /*
     * C++11 says...
     */
#    define MOZ_UTF16_HELPER(s) ...
typedef wchar_t char16_t;
...
#  endif
#endif

@@ +22,3 @@
>     /*
>      * C++11 says char16_t is a distinct builtin type, but Windows's yvals.h
>      * typedefs char16_t as an unsigned short. We would like to alias char16_t

Add a "(prior to MSVC 2015, which implemented C++11's distinct char16_t type)" here while you're in the neighborhood.
Attachment #8545588 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/1aac5e49e4bd

(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #2)
> Add a "(prior to MSVC 2015, which implemented C++11's distinct char16_t
> type)" here while you're in the neighborhood.

I added the comment, worded slightly differently. I also updated another comment. Please make sure the wording of those comments in the the checked-in patch is reasonable.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla38
https://hg.mozilla.org/mozilla-central/rev/1aac5e49e4bd
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
The wording is fine by me, but you have a stray ')' in there:

...implemented C++11's distinct char16_t type)...
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #5)
> The wording is fine by me, but you have a stray ')' in there:
> 
> ...implemented C++11's distinct char16_t type)...

Thanks for pointing that out. I fixed it:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e4246e29bdc
See Also: → 1135583
You need to log in before you can comment on or make changes to this bug.