When developing C++ applications on Windows, the Mingw-w64 toolchain is commonly used to provide GCC-based compilation. In some scenarios, determining the exact version of Mingw-w64 can be important for compatibility checks, verifying build environments, or confirming available features. This tutorial shows how to get Mingw-w64 version using C++.
The Mingw-w64 toolchain provides three macros - __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR, and __MINGW64_VERSION_BUGFIX - which represent the major, minor, and bug fix version numbers of the toolchain, respectively.
The following code concatenates the three macros to output the full version as major.minor.bugfix.
#include <iostream>
int main() {
std::cout << __MINGW64_VERSION_MAJOR << "."
<< __MINGW64_VERSION_MINOR << "."
<< __MINGW64_VERSION_BUGFIX << std::endl;
return 0;
}
Output example:
11.0.0
Leave a Comment
Cancel reply