使用-std = gnu99进行编译时,是否仍应定义_GNU_SOURCE? [英] Should I still define _GNU_SOURCE when I compile with -std=gnu99?

查看:95
本文介绍了使用-std = gnu99进行编译时,是否仍应定义_GNU_SOURCE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一些GNU扩展,并且意识到如果将gnu99设置为要使用的C标准,我可以省略#define _GNU_SOURCE. gnu99是否暗示_GNU_SOURCE还是使用它更安全还是必须使用以避免问题?

I use some GNU extensions and realized that if I set gnu99 as C-standard to use, I can omit #define _GNU_SOURCE. Does gnu99 imply the _GNU_SOURCE or is it still safer to use it or mandatory to avoid problems?

推荐答案

您应该区分语言和库功能; -std = gnu99启用GNU语言功能,_GNU_SOURCE启用GNU库功能.

You should differentiate between language and library features; -std=gnu99 enables GNU language features, _GNU_SOURCE enables GNU library features.

如果您使用任何库功能,建议您定义_GNU_SOURCE,因此对于代码阅读者来说很清楚.另外,当您的代码未(在未提供GCC但提供glibc的平台上)进行编译时,这可能会使情况更加混乱.

I suggest you to define _GNU_SOURCE if you use any library features, so it's clear for readers of your code. Also, this might make things more obvios when your code is (not) compiling on a platform that provides GCC but not glibc.

这篇关于使用-std = gnu99进行编译时,是否仍应定义_GNU_SOURCE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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