Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependencies on unstable MSVC/STL extensions, #18334

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

YexuanXiao
Copy link

@YexuanXiao YexuanXiao commented Dec 17, 2024

and fix non-standard compliant code

Fix some potential issues that may be exposed after upgrading the compiler and dependencies. For detailed explanations, see the comments.

src/host/VtIo.cpp Outdated Show resolved Hide resolved
src/inc/LibraryIncludes.h Outdated Show resolved Hide resolved
@@ -42,10 +42,10 @@ class ConsoleWaitBlock
_In_ IWaitRoutine* const pWaiter);

ConsoleWaitQueue* const _pProcessQueue;
std::_List_const_iterator<std::_List_val<std::_List_simple_types<ConsoleWaitBlock*>>> _itProcessQueue;
typename std::list<ConsoleWaitBlock*>::const_iterator _itProcessQueue;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the use of unstable STL internal names.

@@ -104,7 +104,7 @@ namespace Microsoft::Console::VirtualTerminal
size_t _colorsUsed = 0;
size_t _colorsAvailable = 0;
bool _colorTableChanged = false;
IndexedPixel _foregroundPixel = 0;
IndexedPixel _foregroundPixel = {};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The struct has two members, and allowing the use of = 0 initialization might be an MSVC extension or a bug.

@@ -255,7 +255,7 @@ void Utils::InitializeVT340ColorTable(const std::span<COLORREF> table) noexcept
// - table: a color table to be filled
// Return Value:
// - <none>
constexpr void Utils::InitializeExtendedColorTable(const std::span<COLORREF> table, const bool monochrome) noexcept
void Utils::InitializeExtendedColorTable(const std::span<COLORREF> table, const bool monochrome) noexcept
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the strange constexpr as it might cause the function definition to be discarded, leading to missing symbols.

src/inc/LibraryIncludes.h Outdated Show resolved Hide resolved
@@ -567,10 +567,11 @@ void VtIo::Writer::WriteUTF16(std::wstring_view str) const

// C++23's resize_and_overwrite is too valuable to not use.
// It reduce the CPU overhead by roughly half.
#if !defined(_HAS_CXX23) || !_HAS_CXX23
#if !defined(__cpp_lib_string_resize_and_overwrite) && _MSVC_STL_UPDATE >= 202111L
Copy link
Author

@YexuanXiao YexuanXiao Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using feature test macros instead of MSVC private macros; this will no longer be necessary after upgrading to C++23. The macro _MSVC_STL_UPDATE is documented.

@@ -13,6 +13,7 @@
#include <span>
#include <string_view>
#include <vector>
#include <cassert>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code using assert but did not include the header cassert, rely on the unstable internal include relationship of STL. I think it would be better to fix it.

@@ -165,7 +165,7 @@ namespace Microsoft::Console::Render
// It's important the pool is first so it can be given to the others on construction.
std::pmr::unsynchronized_pool_resource _pool;
std::pmr::vector<std::pmr::wstring> _polyStrings;
std::pmr::vector<std::pmr::basic_string<int>> _polyWidths;
std::pmr::vector<std::pmr::vector<int>> _polyWidths;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used as string nor need the null terminator.

@YexuanXiao YexuanXiao requested a review from lhecker December 17, 2024 23:17
@YexuanXiao YexuanXiao changed the title Update GSL header names, remove dependencies on unstable STL extensio… Remove dependencies on unstable MSVC/STL extensions, Dec 18, 2024
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you for these fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants