Skip to content

Commit a8031b8

Browse files
committed
Renaming cross platform locale typedef to avoid conflict.
1 parent 814caa4 commit a8031b8

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Release/include/cpprest/asyncrt_utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ namespace details
171171
_ASYNCRTIMP ~scoped_c_thread_locale();
172172

173173
#ifdef _MS_WINDOWS
174-
typedef _locale_t locale_t;
174+
typedef _locale_t xplat_locale;
175175
#else
176-
typedef locale_t locale_t;
176+
typedef locale_t xplat_locale;
177177
#endif
178178

179-
static _ASYNCRTIMP locale_t __cdecl c_locale();
179+
static _ASYNCRTIMP xplat_locale __cdecl c_locale();
180180
private:
181181
#ifdef _MS_WINDOWS
182182
std::string m_prevLocale;

Release/src/utilities/asyncrt_utils.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ namespace details
5656
{
5757

5858
std::once_flag g_c_localeFlag;
59-
std::unique_ptr<scoped_c_thread_locale::locale_t, void(*)(scoped_c_thread_locale::locale_t *)> g_c_locale(nullptr, [](scoped_c_thread_locale::locale_t *){});
60-
scoped_c_thread_locale::locale_t scoped_c_thread_locale::c_locale()
59+
std::unique_ptr<scoped_c_thread_locale::xplat_locale, void(*)(scoped_c_thread_locale::xplat_locale *)> g_c_locale(nullptr, [](scoped_c_thread_locale::xplat_locale *){});
60+
scoped_c_thread_locale::xplat_locale scoped_c_thread_locale::c_locale()
6161
{
6262
std::call_once(g_c_localeFlag, [&]()
6363
{
64-
scoped_c_thread_locale::locale_t *clocale = new scoped_c_thread_locale::locale_t();
64+
scoped_c_thread_locale::xplat_locale *clocale = new scoped_c_thread_locale::xplat_locale();
6565
#ifdef _MS_WINDOWS
6666
*clocale = _create_locale(LC_ALL, "C");
6767
if (clocale == nullptr)
6868
{
6969
throw std::runtime_error("Unable to create 'C' locale.");
7070
}
71-
auto deleter = [](scoped_c_thread_locale::locale_t *clocale)
71+
auto deleter = [](scoped_c_thread_locale::xplat_locale *clocale)
7272
{
7373
_free_locale(*clocale);
7474
};
@@ -78,12 +78,12 @@ scoped_c_thread_locale::locale_t scoped_c_thread_locale::c_locale()
7878
{
7979
throw std::runtime_error("Unable to create 'C' locale.");
8080
}
81-
auto deleter = [](scoped_c_thread_locale::locale_t *clocale)
81+
auto deleter = [](scoped_c_thread_locale::xplat_locale *clocale)
8282
{
83-
freelocale(clocale);
83+
freelocale(*clocale);
8484
};
8585
#endif
86-
g_c_locale = std::unique_ptr<scoped_c_thread_locale::locale_t, void(*)(scoped_c_thread_locale::locale_t *)>(clocale, deleter);
86+
g_c_locale = std::unique_ptr<scoped_c_thread_locale::xplat_locale, void(*)(scoped_c_thread_locale::xplat_locale *)>(clocale, deleter);
8787
});
8888
return *g_c_locale;
8989
}
@@ -98,7 +98,7 @@ scoped_c_thread_locale::scoped_c_thread_locale()
9898
throw std::runtime_error("Unable to retrieve current locale.");
9999
}
100100

101-
if(std::strcmp(prevLocale, "C") != 0)
101+
if (std::strcmp(prevLocale, "C") != 0)
102102
{
103103
m_prevLocale = prevLocale;
104104
m_prevThreadSetting = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
@@ -116,26 +116,26 @@ scoped_c_thread_locale::scoped_c_thread_locale()
116116

117117
scoped_c_thread_locale::~scoped_c_thread_locale()
118118
{
119-
if(m_prevThreadSetting != -1)
119+
if (m_prevThreadSetting != -1)
120120
{
121121
setlocale(LC_ALL, m_prevLocale.c_str());
122122
_configthreadlocale(m_prevThreadSetting);
123123
}
124124
}
125125
#else
126126
scoped_c_thread_locale::scoped_c_thread_locale()
127-
: m_prevLocale(nullptr), m_newLocale(nullptr)
127+
: m_prevLocale(nullptr)
128128
{
129-
char * prevLocale = setlocale(LC_ALL, nullptr);
130-
if(prevLocale == nullptr)
129+
char *prevLocale = setlocale(LC_ALL, nullptr);
130+
if (prevLocale == nullptr)
131131
{
132132
throw std::runtime_error("Unable to retrieve current locale.");
133133
}
134134

135-
if(std::strcmp(prevLocale, "C") != 0)
135+
if (std::strcmp(prevLocale, "C") != 0)
136136
{
137137
m_prevLocale = uselocale(c_locale());
138-
if(m_prevLocale == nullptr)
138+
if (m_prevLocale == nullptr)
139139
{
140140
throw std::runtime_error("Unable to set locale");
141141
}
@@ -144,7 +144,7 @@ scoped_c_thread_locale::scoped_c_thread_locale()
144144

145145
scoped_c_thread_locale::~scoped_c_thread_locale()
146146
{
147-
if(m_prevLocale != nullptr)
147+
if (m_prevLocale != nullptr)
148148
{
149149
uselocale(m_prevLocale);
150150
}

0 commit comments

Comments
 (0)