Version: 19.20 (tools version 14.20)
Prior to 2019, MSVC lagged behind Clang and GCC in C++17 conformance. Microsoft restructured its compiler backend (LLVM not adopted, but internal improvements made) and increased collaboration with the ISO C++ committee.
To summarize the landscape of Microsoft Visual C++ between 2019 and 2021:
Here’s a solid, practical piece of code written for Microsoft Visual C++ 2019 (and compatible with 2021 / later MSVC toolsets). microsoft visual c 2019 2021
It demonstrates modern C++ (C++17/20 features available in MSVC) with:
// logger.h #pragma once#include <memory> #include <string> #include <chrono> #include <fstream> #include <mutex>
enum class LogLevel Info, Warning, Error ; Version: 19
class Logger public: static Logger& instance(); // Singleton access void log(LogLevel level, const std::string& message); void setOutputFile(const std::string& path); // optional file logging
private: Logger(); ~Logger(); std::string levelToString(LogLevel level) const; std::string currentTimestamp() const;
std::unique_ptr<std::ofstream> fileStream; std::mutex mtx;
;
// logger.cpp
#include "logger.h"
#include <iostream>
#include <iomanip>
#include <ctime>
Logger& Logger::instance()
static Logger instance;
return instance;
Logger::Logger() = default;
Logger::~Logger() = default;
void Logger::setOutputFile(const std::string& path)
std::lock_guard<std::mutex> lock(mtx);
fileStream = std::make_unique<std::ofstream>(path, std::ios::app);
if (!fileStream->is_open())
std::cerr << "Warning: Could not open log file: " << path << std::endl;
fileStream.reset();
void Logger::log(LogLevel level, const std::string& message)
std::lock_guard<std::mutex> lock(mtx);
std::string formatted = "[" + currentTimestamp() + "] " +
levelToString(level) + ": " + message;
// Console output
std::cout << formatted << std::endl;
// File output if available
if (fileStream && fileStream->is_open())
(*fileStream) << formatted << std::endl;
fileStream->flush();
std::string Logger::levelToString(LogLevel level) const
switch (level)
case LogLevel::Info: return "INFO";
case LogLevel::Warning: return "WARN";
case LogLevel::Error: return "ERROR";
default: return "UNKNOWN";
std::string Logger::currentTimestamp() const
auto now = std::chrono::system_clock::now();
auto now_c = std::chrono::system_clock::to_time_t(now);
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
now.time_since_epoch()) % 1000;
std::tm now_tm;
localtime_s(&now_tm, &now_c); // MSVC secure version
std::ostringstream oss;
oss << std::put_time(&now_tm, "%Y-%m-%d %H:%M:%S")
<< '.' << std::setfill('0') << std::setw(3) << ms.count();
return oss.str();
// main.cpp – example usage
#include "logger.h"
#include <thread>
#include <vector>
void workerTask(int id)
Logger::instance().log(LogLevel::Info, "Worker " + std::to_string(id) + " started");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Logger::instance().log(LogLevel::Info, "Worker " + std::to_string(id) + " finished");
int main()
Logger::instance().setOutputFile("app.log");
Logger::instance().log(LogLevel::Info, "Application starting");
std::vector<std::thread> threads;
for (int i = 1; i <= 5; ++i)
threads.emplace_back(workerTask, i);
for (auto& t : threads)
t.join();
Logger::instance().log(LogLevel::Warning, "This is a warning example");
Logger::instance().log(LogLevel::Error, "This is an error example");
Logger::instance().log(LogLevel::Info, "Application finished");
return 0;
To understand why Microsoft Visual C++ 2019 2021 is on your PC, you need to understand how Windows applications are built.
When a developer writes a program in C++, they rely on standard libraries (chunks of pre-written code) to handle basic tasks like managing memory, processing input, or drawing a window. These libraries are called the Runtime. To summarize the landscape of Microsoft Visual C++
The Redistributable is the Microsoft-approved installer that puts those DLLs onto your system. Without the correct redistributable, the program refuses to launch, throwing an error like: "The code execution cannot proceed because VCRUNTIME140.dll was not found."
This paper examines the Microsoft Visual C++ (MSVC) compiler toolchain as part of Visual Studio 2019 (released 2019) and its major updates through 2021. It focuses on standards conformance (C++17/20), security enhancements, build throughput improvements, and the introduction of the /std:c++latest mode. The study finds that between 2019 and 2021, MSVC achieved near-full support for C++17, substantial C++20 feature completion, and significant parallel compilation optimizations, while maintaining backward compatibility with legacy code.