Skip to content

Commit 223d4fa

Browse files
committed
MSVC compatibility fixes
1 parent 47baca5 commit 223d4fa

File tree

4 files changed

+36
-27
lines changed

4 files changed

+36
-27
lines changed

nh3api/core/nh3api_std/algorithm.hpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -950,18 +950,9 @@ NoThrowForwardIt uninitialized_move(InputIt first,
950950
}
951951
// #endif
952952

953-
template<class T, class Size> NH3API_CONSTEXPR_CPP_20
954-
void init_array(T* first, Size n)
955-
{
956-
#if NH3API_DEBUG
957-
verify_range_n(first, n);
958-
#endif
959-
init_array_impl(first, n, tt::is_nothrow_default_constructible<T>());
960-
}
961-
962953
template<class T, class Size>
963954
NH3API_FORCEINLINE NH3API_CONSTEXPR_CPP_20
964-
void init_array_impl(T* first, Size n, tt::false_type)
955+
T* init_array_impl(T* first, Size n, tt::false_type)
965956
{
966957
T* current = first;
967958
NH3API_TRY
@@ -975,16 +966,27 @@ void init_array_impl(T* first, Size n, tt::false_type)
975966
destroy(first, current);
976967
NH3API_RETHROW
977968
}
969+
return current;
978970
}
979971

980972
template<class T, class Size>
981973
NH3API_FORCEINLINE NH3API_CONSTEXPR_CPP_20
982-
void init_array_impl(T* first, Size n, tt::true_type)
974+
T* init_array_impl(T* first, Size n, tt::true_type)
983975
{
984976
T* current = first;
985977
for (; n > 0; (void) ++current, --n)
986978
::new (const_cast<void*>(static_cast<const volatile void*>(
987-
addressof(*current)))) T;
979+
nh3api::addressof(*current)))) T;
980+
return current;
981+
}
982+
983+
template<class T, class Size> NH3API_CONSTEXPR_CPP_20
984+
T* init_array(T* first, Size n)
985+
{
986+
#if NH3API_DEBUG
987+
verify_range_n(first, n);
988+
#endif
989+
return init_array_impl(first, n, tt::is_nothrow_default_constructible<T>());
988990
}
989991

990992
template <typename InputIterator, typename OutputIterator>

nh3api/core/nh3api_std/exe_vector.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ struct exe_vector_helper
214214
}
215215

216216
NH3API_CONSTEXPR_CPP_20
217-
void default_fill(pointer first, size_type count)
217+
pointer default_fill(pointer first, size_type count)
218218
{
219-
nh3api::uninitialized_default_construct_n(first, count, alloc);
219+
return nh3api::uninitialized_default_construct_n(first, count, alloc);
220220
}
221221

222222
public:
@@ -385,10 +385,10 @@ struct exe_vector_helper<exe_allocator<T> >
385385
}
386386

387387
NH3API_FORCEINLINE
388-
void default_fill(pointer first, size_type count)
388+
pointer default_fill(pointer first, size_type count)
389389
NH3API_NOEXCEPT_EXPR(nh3api::tt::is_nothrow_default_constructible<value_type>::value)
390390
{
391-
nh3api::init_array(first, count);
391+
return nh3api::init_array(first, count);
392392
}
393393

394394
public:

nh3api/core/nh3api_std/nh3api_std.hpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -339,25 +339,29 @@
339339
#endif
340340

341341
#ifndef NH3API_CONSTEXPR_CPP_20
342-
#ifdef _CONSTEXPR20
343-
#define NH3API_CONSTEXPR_CPP_20 _CONSTEXPR20
342+
#ifdef _CONSTEXPR20 // avoid stupid MSVC double inline warning
343+
#define NH3API_CONSTEXPR_CPP_20 constexpr
344344
#else
345345
#define NH3API_CONSTEXPR_CPP_20
346346
#endif
347347
#endif
348348

349349
#ifndef NH3API_CONSTEXPR_CPP_17
350-
#ifdef _CONSTEXPR17
351-
#define NH3API_CONSTEXPR_CPP_17 _CONSTEXPR17
350+
#ifdef _CONSTEXPR17 // avoid stupid MSVC double inline warning
351+
#define NH3API_CONSTEXPR_CPP_17 constexpr
352352
#else
353353
#define NH3API_CONSTEXPR_CPP_17
354354
#endif
355355
#endif
356356

357357
#ifndef NH3API_CONSTEXPR_CPP_14
358-
#ifdef _CONSTEXPR17
359-
#define NH3API_CONSTEXPR_CPP_14 constexpr
360-
#else
358+
#ifdef __cpp_constexpr
359+
#if __cpp_constexpr >= 201304L
360+
#define NH3API_CONSTEXPR_CPP_14 constexpr
361+
#else
362+
#define NH3API_CONSTEXPR_CPP_14
363+
#endif
364+
#else
361365
#define NH3API_CONSTEXPR_CPP_14
362366
#endif
363367
#endif

nh3api/hd_mod.hpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ bool isHDPlusPresent(Patcher* patcher)
9797
NH3API_FORCEINLINE
9898
POINT getHDModResolution(Patcher* patcher)
9999
{
100-
POINT result = { .x = getHDModVariable<int32_t, 0>(patcher, "HD.Option.RezX"),
101-
.y = getHDModVariable<int32_t, 0>(patcher, "HD.Option.RezY") };
100+
POINT result;
101+
result.x = getHDModVariable<int32_t, 0>(patcher, "HD.Option.RezX");
102+
result.y = getHDModVariable<int32_t, 0>(patcher, "HD.Option.RezY");
102103
return result;
103104
}
104105

@@ -129,7 +130,9 @@ POINT getScreenResolution(Patcher* patcher)
129130
}
130131
else
131132
{
132-
POINT result = { .x = 800, .y = 600 };
133+
POINT result;
134+
result.x = 800;
135+
result.y = 600;
133136
return result;
134137
}
135138
}
@@ -169,7 +172,7 @@ struct is_wine_present_impl
169172
{
170173
library = GetModuleHandleA("ntdll.dll");
171174
if ( library ) // I *really* hope you're running it with windows or WINE
172-
func = GetProcAddress(status.second, "wine_get_version");
175+
func = GetProcAddress(library, "wine_get_version");
173176
initialized = true;
174177
}
175178
if ( library )

0 commit comments

Comments
 (0)