Should I still define _GNU_SOURCE when I compile with -std=gnu99?

独自空忆成欢 提交于 2020-01-23 13:19:06

问题


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?


回答1:


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

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.



来源:https://stackoverflow.com/questions/18676944/should-i-still-define-gnu-source-when-i-compile-with-std-gnu99

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