tags:

views:

1123

answers:

3

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.

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
+3  A: 

If you really only want the directory name, use the string constant macro P_tmpdir, defined in <stdio.h>.

gnud
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
I need to create a FIFO file in a temporary directory so I use dirname(tempnam...)
Jack

related questions