When using mkstemp() in my C source, I get the gcc warning:
warning: implicit declaration of function ‘mkstemp’
Why?
I use gcc 6.4.0 on a debian GNU/Linux system.
<stdlib.h> is included. I use other POSIX functions (such as
ftruncate() and open()) that are not part of ISO C in the same source
file, but get a warning for mkstemp() only.
I tried using -D_POSIX_C_SOURCE=200112L, but still get the warning.
Philipp Klaus Krause <pkk@spth.de> wrote:
When using mkstemp() in my C source, I get the gcc warning:
warning: implicit declaration of function ‘mkstemp’
Why?
I use gcc 6.4.0 on a debian GNU/Linux system.
<stdlib.h> is included. I use other POSIX functions (such as
ftruncate() and open()) that are not part of ISO C in the same source
file, but get a warning for mkstemp() only.
I tried using -D_POSIX_C_SOURCE=200112L, but still get the warning.
Try '-D_POSIX_C_SOURCE=200809' instead. That's what's required
according to the up-to-date version of the man page (see <http://man7.org/linux/man-pages/man3/mkstemp.3.html>), and it
works for me. The (somewhat out-dated) man page on my system
also claims that '_POSIX_C_SOURCE=200112L' would do the the
trick, but it doesn't.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 380 |
Nodes: | 16 (2 / 14) |
Uptime: | 53:30:21 |
Calls: | 8,145 |
Calls today: | 1 |
Files: | 13,085 |
Messages: | 5,858,832 |