警告:使用`mktemp的'是危险的 [英] warning: the use of `mktemp' is dangerous
问题描述
我怎样才能坐席以下的gcc从连接器警告preSS:
How can I suppress following warning from gcc linker:
警告:使用 mktemp的'是危险的,更好的使用
mkstemp'
warning: the use of mktemp' is dangerous, better use
mkstemp'
我不知道这是最好使用mkstemp(),但由于某种原因,我不得不使用mktemp的()函数。
I do know that it's better to use mkstemp() but for some reason I have to use mktemp() function.
推荐答案
我猜是因为你把它传递给只接受路径名作为参数,而不是文件描述符或文件<库您需要的路径/ code>指针。如果是这样,您可以创建
mkdtemp
一个临时目录,并把你的文件存在,实际的名字是那么不重要,因为路径是因为该目录已经是独一无二的。
I guess you need the path because you pass it to a library that only accepts path names as argument and not file descriptors or FILE
pointers. If so you can create a temp dir with mkdtemp
and place your file there, the actual name is then unimportant because the path is already unique because of the directory.
这篇关于警告:使用`mktemp的'是危险的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!