What does #define _POSIX_SOURCE mean?

后端 未结 1 1377
予麋鹿
予麋鹿 2021-01-12 01:36

What advantages does using #define _POSIX_SOURCE in C confer to my program? Can I access more libraries in my program or I can call some functions which are pre

相关标签:
1条回答
  • 2021-01-12 01:56

    It allows you to use functions that are not part of the standard C library but are part of the POSIX.1 (IEEE Standard 1003.1) standard. Using the macros described in feature_test_macros allows you to control the definitions exposed by the system header files.

    As far as I know _POSIX_SOURCE is obsolete and you should use _POSIX_C_SOURCE instead.

    For example, if you want to use strndup, you have to use

    #define _POSIX_C_SOURCE 200809L
    

    See also

    • 1.3.4 Feature Test Macros
    • 5.12 Posix Variants
    • man 7 feature_test_macros
    0 讨论(0)
提交回复
热议问题