Skip to content

Commit f3ec723

Browse files
garethsbras0219-msft
authored andcommitted
Don't use the U() preprocessor macro in public headers (#693)
* Don't use the ``U()`` preprocessor macro in public headers, in order to work when ``_TURN_OFF_PLATFORM_STRING`` is defined. * Add the explanation of the 'U' macro (and the use of '_TURN_OFF_PLATFORM_STRING') taken from the FAQ, close to its definition.
1 parent fea848e commit f3ec723

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Release/include/cpprest/details/basic_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ typedef std::stringstream stringstream_t;
8080
#endif // endif _UTF16_STRINGS
8181

8282
#ifndef _TURN_OFF_PLATFORM_STRING
83+
// The 'U' macro can be used to create a string or character literal of the platform type, i.e. utility::char_t.
84+
// If you are using a library causing conflicts with 'U' macro, it can be turned off by defining the macro
85+
// '_TURN_OFF_PLATFORM_STRING' before including the C++ REST SDK header files, and e.g. use '_XPLATSTR' instead.
8386
#define U(x) _XPLATSTR(x)
8487
#endif // !_TURN_OFF_PLATFORM_STRING
8588

Release/include/cpprest/details/http_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ namespace details
5858

5959
static compression_algorithm to_compression_algorithm(const utility::string_t& alg)
6060
{
61-
if (U("gzip") == alg)
61+
if (_XPLATSTR("gzip") == alg)
6262
{
6363
return compression_algorithm::gzip;
6464
}
65-
else if (U("deflate") == alg)
65+
else if (_XPLATSTR("deflate") == alg)
6666
{
6767
return compression_algorithm::deflate;
6868
}

0 commit comments

Comments
 (0)