[LyX/master] Fix C++20 compilation on systems where char_type is wchar_t

Yuriy Skalko yuriy.skalko at gmail.com
Wed Dec 30 07:43:52 UTC 2020


commit cafa1d4ae4fca5abc72dfbb6d49014a48d538dd8
Author: Yuriy Skalko <yuriy.skalko at gmail.com>
Date:   Tue Dec 29 16:54:37 2020 +0200

    Fix C++20 compilation on systems where char_type is wchar_t
---
 src/Buffer.cpp            |    2 +-
 src/Server.cpp            |    2 +-
 src/mathed/MathParser.cpp |    4 ++--
 src/tex2lyx/Parser.cpp    |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ddce2db..3a6ae64 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1771,7 +1771,7 @@ Buffer::ExportStatus Buffer::makeLaTeXFile(FileName const & fname,
 	catch (EncodingException const & e) {
 		docstring const failed(1, e.failed_char);
 		ostringstream oss;
-		oss << "0x" << hex << e.failed_char << dec;
+		oss << "0x" << hex << static_cast<uint32_t>(e.failed_char) << dec;
 		if (getParFromID(e.par_id).paragraph().layout().pass_thru) {
 			docstring msg = bformat(_("Uncodable character '%1$s'"
 						  " (code point %2$s)"),
diff --git a/src/Server.cpp b/src/Server.cpp
index 6549228..e2e9d6a 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -866,7 +866,7 @@ int LyXComm::startPipe(string const & file, bool write)
 	if (!write) {
 		// Make sure not to call read_ready after destruction.
 		weak_ptr<void> tracker = tracker_.p();
-		theApp()->registerSocketCallback(fd, [=](){
+		theApp()->registerSocketCallback(fd, [this, tracker](){
 				if (!tracker.expired())
 					read_ready();
 			});
diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index dd43dd9..478e906 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -370,9 +370,9 @@ ostream & operator<<(ostream & os, Token const & t)
 		os << '\\' << to_utf8(cs);
 	}
 	else if (t.cat() == catLetter)
-		os << t.character();
+		os << static_cast<uint32_t>(t.character());
 	else
-		os << '[' << t.character() << ',' << t.cat() << ']';
+		os << '[' << static_cast<uint32_t>(t.character()) << ',' << t.cat() << ']';
 	return os;
 }
 
diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp
index 67e0323..e4eb9b4 100644
--- a/src/tex2lyx/Parser.cpp
+++ b/src/tex2lyx/Parser.cpp
@@ -854,7 +854,7 @@ void Parser::tokenize_one()
 	}
 
 	case catIgnore: {
-		cerr << "ignoring a char: " << c << "\n";
+		cerr << "ignoring a char: " << static_cast<uint32_t>(c) << "\n";
 		break;
 	}
 


More information about the lyx-cvs mailing list