#define _POSIX_SOURCE是什么意思? [英] What does #define _POSIX_SOURCE mean?

查看:647
本文介绍了#define _POSIX_SOURCE是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在C语言中使用#define _POSIX_SOURCE,那么我在程序中获得了什么好处.我可以在程序中访问更多的库,还是可以调用直接存在于C中的某些函数.我的意思是,这个神秘的宏到底意味着什么?

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?

推荐答案

它允许您使用不属于标准C库但属于POSIX.1(IEEE标准1003.1)标准的函数.使用中描述的宏 feature_test_macros 允许您控制公开的定义 通过系统头文件.

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.

据我所知_POSIX_SOURCE已过时,您应该改用_POSIX_C_SOURCE.

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

例如,如果要使用 strndup ,则必须使用

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

#define _POSIX_C_SOURCE 200809L

另请参见

  • 1.3.4 Feature Test Macros
  • 5.12 Posix Variants
  • man 7 feature_test_macros

这篇关于#define _POSIX_SOURCE是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆