What is the purpose of features.h header?

前端 未结 4 1519
北海茫月
北海茫月 2020-12-29 08:15

What is the purpose of the features.h header? Why and when can it be used in my code?

Does it define source features supported by the system? Or does i

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 09:04

    The features.h header file provides various macro definitions that indicate standard conformance to other header files, i.e. which features (hence the name) should be turned on or off depending on which standard the user wishes to use.

    Most C/C++ compilers have command line options to handle standards conformance. Let's take GCC as an example: when you pass the -std=gnu9x option, you ask for the GNU dialect of the C99 standard. The features.h header makes sure that all other headers that include it will turn exactly those features on or off that are needed to support this particular dialect. This is achieved by #define -ing or #undef - ing some "intermediate" macros.

    As a bonus, features.h also provides the glibc version information macros as well, and various other bits & bobs.

提交回复
热议问题