GTK 1.2.6 fanboy
GTK 1.2.6 fanboy

Reputation: 879

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

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?

Upvotes: 4

Views: 1562

Answers (1)

fuz
fuz

Reputation: 92966

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.

Upvotes: 2

Related Questions