Created
January 5, 2024 03:36
-
-
Save noqisofon/fecd19531093972b9768ac3002de6d1d to your computer and use it in GitHub Desktop.
( ノ╹◡◡╹)ノ C++ のバージョンを判別したいよなー、俺もな~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#ifdef _MSVC_LANG | |
# if _MSVC_LANG >= 201402L | |
# define HOGE_LANGUAGE_ENABLE_CXX14 | |
# endif //* _MSVC_LANG <= 201402L */ | |
# if _MSVC_LANG >= 201703L | |
# define HOGE_LANGUAGE_ENABLE_CXX17 | |
# endif //* _MSVC_LANG <= 201703L */ | |
# if _MSVC_LANG >= 202002L | |
# define HOGE_LANGUAGE_ENABLE_CXX20 | |
# endif //* _MSVC_LANG <= 202002L */ | |
#else /* def _MSVC_LANG */ | |
# if __cplusplus >= 201402L | |
# define HOGE_LANGUAGE_ENABLE_CXX14 | |
# endif //* __cplusplus <= 201402L */ | |
# if __cplusplus >= 201703L | |
# define HOGE_LANGUAGE_ENABLE_CXX17 | |
# endif //* __cplusplus <= 201703L */ | |
# if __cplusplus >= 202002L | |
# define HOGE_LANGUAGE_ENABLE_CXX20 | |
# endif //* __cplusplus <= 202002L */ | |
#endif /* !def __cplusplus */ | |
auto main() -> int { | |
#if defined( HOGE_LANGUAGE_ENABLE_CXX20 ) | |
std::cout << "C++20 でビルドされちょるよ。" << std::endl; | |
#elif defined( HOGE_LANGUAGE_ENABLE_CXX17 ) | |
std::cout << "C++17 でビルドされちょるよ。" << std::endl; | |
#elif defined( HOGE_LANGUAGE_ENABLE_CXX14 ) | |
std::cout << "C++14 でビルドされちょるよ。" << std::endl; | |
#else | |
std::cout << "ようわからん C++ でビルドされちょるよ。" << std::endl; | |
#endif | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment