What does #define _POSIX_SOURCE mean?

你离开我真会死。 提交于 2020-01-03 17:17:12

问题


If I use #define _POSIX_SOURCE in C so then what advantage do i get in my program. Can I access more libraries in my program or I can call some functions which are present directly in C. I mean what does this mysterious macros means after all?


回答1:


It allows you to use function 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


来源:https://stackoverflow.com/questions/48332332/what-does-define-posix-source-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!