Skip to content

cppreference Replacing text macros # Predefined macros

__cplusplus

denotes the version of C++ standard that is being used, expands to value :

199711L(until C++11),

201103L(C++11),

201402L(C++14),

201703L(C++17), or

202002L(C++20) (macro constant)

NOTE:

__STDC_HOSTED__(C++11)

expands to the integer constant 1 if the implementation is hosted (runs under an OS), 0 if freestanding (runs without an OS) (macro constant)

__FILE__ and__LINE__

expands to the name of the current file, as a character string literal, can be changed by the #line directive (macro constant)

expands to the source file line number, an integer constant, can be changed by the #line directive (macro constant)

__DATE__ and __TIME__

expands to the date of translation, a character string literal of the form "Mmm dd yyyy". The first character of "dd" is a space if the day of the month is less than 10. The name of the month is as if generated by std::asctime() (macro constant)

expands to the time of translation, a character string literal of the form "hh:mm:ss" (macro constant)

__STDCPP_DEFAULT_NEW_ALIGNMENT__(C++17)

expands to an std::size_t literal whose value is the alignment guaranteed by a call to alignment-unaware operator new (larger alignments will be passed to alignment-aware overload, such as operator new(std::size_t, std::align_val_t) (macro constant)

补充

__PRETTY_FUNCTION__

stackoverflow What's the difference between PRETTY_FUNCTION, FUNCTION, func?