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

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

问题描述

在 C 中使用 #define _POSIX_SOURCE 对我的程序有什么好处?我可以在我的程序中访问更多的库,或者我可以调用一些直接存在于 C 中的函数.这个宏是做什么用的?

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 present directly in C. What is this macro used for?

推荐答案

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

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.

据我所知 _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

另见

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

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