I'm using tempnam() only to get the directory name, so this security warning does not apply to my case. How can I disable it? I couldn't find any switches to do it.
views:
1123answers:
3
A:
You can use GCC's -Wno-deprecated-declarations
option to disable all warnings like this. I suggest you handle the warning properly, though, and take the suggestion of the compiler.
strager
2009-02-12 13:42:56
+3
A:
If you really only want the directory name, use the string constant macro P_tmpdir
, defined in <stdio.h>
.
gnud
2009-02-12 13:46:54
A:
"The tempnam() function returns a pointer to a string that is a valid filename, and such that a file with this name did not exist when tempnam() checked."
The warning arises because of the race condition between checking and a later creating of the file.
You want to only get the directory name? What should that be good for?
Like stranger already said, you may disable this (and similar warnings) using -Wno-deprecated-declarations.
bothie
2009-02-12 13:47:27
I need to create a FIFO file in a temporary directory so I use dirname(tempnam...)
Jack
2009-02-12 13:59:31