禁止警告:使用`mktemp'是危险的 [英] Suppress warning: the use of `mktemp' is dangerous

查看:372
本文介绍了禁止警告:使用`mktemp'是危险的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何禁止gcc链接器发出以下警告:

How can I suppress following warning from gcc linker:

警告:'mktemp'的使用是危险的,更好的使用'mkstemp'

我知道最好使用 mkstemp()但由于某些原因我必须使用 mktemp()函数。

I do know that it's better to use mkstemp() but for some reason I have to use mktemp() function.

推荐答案

它到只接受路径名称作为参数而不是文件描述符或 FILE 指针的库。如果是这样,你可以使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆