https://github.com/thecompez/predefination
Some patches for __cplusplus macro.
https://github.com/thecompez/predefination
Last synced: 11 months ago
JSON representation
Some patches for __cplusplus macro.
- Host: GitHub
- URL: https://github.com/thecompez/predefination
- Owner: TheCompez
- License: mit
- Created: 2018-07-11T17:18:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-20T14:26:53.000Z (over 4 years ago)
- Last Synced: 2024-11-19T20:53:04.019Z (over 1 year ago)
- Language: C++
- Size: 59.6 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Predefination
**Some patches for __cplusplus macro.**
===================================
In MSVC 2017 **__cplusplus** macro returns **199711** value :( that is wrong! you can use this patch for fix this problem in Microsoft **MSVC2017** compiler. :)
```cpp
#include
#include "include/macro.hpp"
using namespace std;
using namespace Utility;
int main()
{
MacroPatch mPatch;
cout << "Hello World!" << endl;
cout << "C++ Standard Version : " << __cplusplus << endl;
cout << "C++ Standard String : " << mPatch.__cPlusPlusStandard() << endl;
#if defined(__PROJECT_MSVC__)
cout << "C++ Standard Version (with bug fix in MSVC : " << __PROJECT_CPP_VALUE__ << endl;
cout << "C++ Standard Value (with bug fix in MSVC using function: " << mPatch.__cPlusPlusValue() << endl;
cout << "C++ Standard Version (with bug fix in MSVC using function: " << mPatch.__cPlusPlusVersion() << endl;
cout << "Compiler name using flag: " << mc.__cPlusPlus(true) << endl;
#else
cout << "Standard value: " << mPatch.__cPlusPlusValue() << endl;
cout << "Standard version: " << mPatch.__cPlusPlusVersion() << endl;
#endif
return 0;
}
```
**Note:**
Make sure the default language is set to version 20 in CMakeLists.txt file.
```
CMAKE_CXX_STANDARD 20
```
**Result:**
```
Hello World!
C++ Standard Version : 202002
C++ Standard String : C++20
Standard value: 202002
Standard version: 202002
```