Skip to content

Commit 71cffaa

Browse files
committed
Address warnings for std::aligned_storage_t and va_start/va_end in newer VS toolset
1 parent e07ada4 commit 71cffaa

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

TextLayoutSampler.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<PropertyGroup Label="Configuration">
2828
<ConfigurationType>Application</ConfigurationType>
2929
<UseDebugLibraries>true</UseDebugLibraries>
30-
<PlatformToolset>v142</PlatformToolset>
30+
<PlatformToolset>v143</PlatformToolset>
3131
<CharacterSet>Unicode</CharacterSet>
3232
</PropertyGroup>
3333
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -63,7 +63,7 @@
6363
</UndefinePreprocessorDefinitions>
6464
<PrecompiledHeader>NotUsing</PrecompiledHeader>
6565
<PrecompiledHeaderFile>precomp.h</PrecompiledHeaderFile>
66-
<AdditionalOptions>/ifcSearchDir $(IntDir)</AdditionalOptions>
66+
<AdditionalOptions>/ifcSearchDir $(IntDir) /utf-8</AdditionalOptions>
6767
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
6868
<DisableSpecificWarnings>
6969
</DisableSpecificWarnings>

source/Common.FastVector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ class fast_vector : public fast_vector<T, 0, ShouldInitializeElements>
765765
private:
766766
constexpr array_ref<T> GetFixedSizeArrayData() noexcept
767767
{
768-
return array_ref<T>(reinterpret_cast<T*>(std::data(fixedSizedArrayData_)), std::size(fixedSizedArrayData_));
768+
return array_ref<T>(reinterpret_cast<T*>(std::data(fixedSizedArrayData_)), DefaultArraySize);
769769
}
770770

771771
private:
@@ -776,7 +776,7 @@ class fast_vector : public fast_vector<T, 0, ShouldInitializeElements>
776776
// Note Visual Studio 2017 15.8 requires you to declare _ENABLE_EXTENDED_ALIGNED_STORAGE
777777
// if your type T is > max_align_t.
778778
//
779-
std::aligned_storage_t<sizeof(T), alignof(T)> fixedSizedArrayData_[DefaultArraySize];
779+
/*[[uninitialized]]*/ alignas(T) std::byte fixedSizedArrayData_[sizeof(T) * DefaultArraySize];
780780
};
781781

782782
#ifdef USE_GSL_SPAN_INSTEAD_OF_ARRAY_REF

source/MainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class MainWindow
155155
void AppendLogUnformatted(char16_t const* logMessage);
156156
void ShowMessageAndAppendLog(char16_t const* logMessage, ...);
157157
void ShowMessageAndAppendLogUnformatted(char16_t const* logMessage);
158-
HRESULT ShowMessageIfError(char16_t const* logMessage, HRESULT hr, ...);
158+
HRESULT ShowMessageIfError(char16_t const* logMessage, /*HRESULT hr,*/ ...);
159159

160160
void ClearLog();
161161

source/MainWindow.ixx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//----------------------------------------------------------------------------
1+
//----------------------------------------------------------------------------
22
// History: 2015-06-19 Dwayne Robinson - Created
33
// 2022-03-17 Updated for high DPI
44
//----------------------------------------------------------------------------
@@ -3291,6 +3291,7 @@ void MainWindow::AppendLogCached(char16_t const* logMessage, ...)
32913291
buffer[0] = 0;
32923292

32933293
StringCchVPrintf(OUT ToWChar(buffer), countof(buffer), ToWChar(logMessage), argList);
3294+
va_end(argList);
32943295
cachedLog_ += buffer;
32953296
}
32963297

@@ -3319,6 +3320,7 @@ void MainWindow::AppendLog(char16_t const* logMessage, ...)
33193320
buffer[0] = 0;
33203321

33213322
StringCchVPrintf(OUT ToWChar(buffer), countof(buffer), ToWChar(logMessage), argList);
3323+
va_end(argList);
33223324
AppendLogUnformatted(buffer);
33233325
}
33243326

@@ -3342,22 +3344,28 @@ void MainWindow::ShowMessageAndAppendLog(char16_t const* logMessage, ...)
33423344
buffer[0] = 0;
33433345

33443346
StringCchVPrintf(OUT ToWChar(buffer), countof(buffer), ToWChar(logMessage), argList);
3347+
va_end(argList);
33453348
ShowMessageAndAppendLogUnformatted(buffer);
33463349
}
33473350

33483351

3349-
HRESULT MainWindow::ShowMessageIfError(char16_t const* logMessage, HRESULT hr, ...)
3352+
HRESULT MainWindow::ShowMessageIfError(char16_t const* logMessage, /*HRESULT hr,*/ ...)
33503353
{
3354+
va_list originalList, argList;
3355+
va_start(originalList, logMessage);
3356+
va_copy(argList, originalList);
3357+
HRESULT hr = va_arg(originalList, HRESULT);
3358+
33513359
if (FAILED(hr))
33523360
{
3353-
va_list argList;
3354-
va_start(argList, logMessage);
33553361
char16_t buffer[1000];
33563362
buffer[0] = 0;
33573363

33583364
StringCchVPrintf(OUT ToWChar(buffer), countof(buffer), ToWChar(logMessage), argList);
33593365
MainWindow::ShowMessageAndAppendLogUnformatted(buffer);
33603366
}
3367+
va_end(argList);
3368+
va_end(originalList);
33613369
return hr;
33623370
}
33633371

0 commit comments

Comments
 (0)