Home [C++] g++의 c++지원 version
Post
Cancel

[C++] g++의 c++지원 version

Overview

g++ 버전에 따라 c++ 지원 버전이 다르기 때문에 해당 내용을 정리한다.

Contents

C++ GCC Description
C++23 GCC 11 ~ -std=c++2b, -std=gnu++2b
C++20 GCC 8 ~ -std=c++20, -std=c++2a, -std=gnu++20
C++17 GCC 5 ~ GCC 11 (default) ~ -std=c++17, -std=gnu++17
C++14 GCC 4.9 ~ GCC 6.1 (default) ~ GCC 10 -std=c++14, -std=gnu++14
C++11 GCC 4.7 ~ GCC 5.x (default?) ~ -std=c++11, -std=gnu++11
C++0x GCC 4.3 ~ GCC 4.6 (experimental)  
C++98  ~ GCC 6.0 (default?) -std=c++98

Language standard pre define macro

Name Macro Standard
C89 _STDC_ ANSI X3.159-1989
C90 _STDC_ ISO/IEC 9899:1990
C94 _STDC_VERSION_ = 199409L ISO/IEC 9899-1:1994
C99 _STDC_VERSION_ = 199901L ISO/IEC 9899:1999
C11 _STDC_VERSION_ = 201112L ISO/IEC 9899:2011
C18 _STDC_VERSION_ = 201710L ISO/IEC 9899:2018
C++98 __cplusplus = 199711L ISO/IEC 14882:1998
C++11 __cplusplus = 201103L ISO/IEC 14882:2011
C++14 __cplusplus = 201402L ISO/IEC 14882:2014
C++17 __cplusplus = 201703L ISO/IEC 14882:2017
C++/CLI __cplusplus_cli = 200406L ECMA-372
DSP-C   ISO/IEC JTC1/SC22 WG14/N854
EC++ __embedded_cplusplus Embedded C++
1
2
3
4
5
6
7
8
9
#if defined(_MSVC_LANG)  // MS compiler has different __cplusplus value.
#   if _MSVC_LANG < 201703
#       error Please compile for C++17 or higher
#   endif
#else  // All other compilers.
#   if __cplusplus < 201703
#       error Please compile for C++17 or higher
#   endif
#endif
This post is licensed under CC BY 4.0 by the author.