EiffelStudio 编译错误:使用 'tempnam' 很危险,最好使用 'mkstemp'
EiffelStudio compile error: The use of `tempnam' is dangerous, better use `mkstemp'
我正在使用通过 AUR 在 Arch 中安装的 eiffelstudio-bin 17.05.100416-1。
当我尝试运行默认的 hello world 项目时,我在"错误列表"选项卡中出现此错误:
C Compiler Error: The use of `tempnam' is dangerous, better use `mkstemp' FILE_NAME.c_tempnam (elks) 132, 4
Error code: C Compiler Error
Error: External C/C++ compilation failed.
What to do: Check the external C/C++ compilation for details.
The use of `tempnam' is dangerous, better use `mkstemp'
在"输出"选项卡的"外部编译"下:
Preparing C compilation
Compiling C code in C1
Compiling C code in E1
/home/rivamarco/.es/eiffel_user_files/17.05/precomp/spec/linux-x86-64/EIFGENs/base-scoop-safe/W_code/preobj.o(Cobj8.o): in function "F236_6717":
(.text+0x7d19): warning: the use of `tempnam' is dangerous, better use `mkstemp'
C compilation completed
显然,hello world程序不起作用。
我正在使用 gcc 7.2.1+20171224-2,如果它有用的话。
我能做什么?
提前谢谢。
什么不起作用?
根据评论,警告并未阻止程序按预期运行。但是,该程序在没有终端的情况下启动,其输出不可见。
为什么我会收到警告?
标准库的代码是跨平台的。而某些平台同时提供两种功能(一个用于创建临时文件,另一个用于构建临时文件名),而其他平台仅提供第二个功能。Eiffel 代码仅支持所有平台上可用的函数,即构建临时文件名的函数。在某些时候,第一组平台上的函数被标记为已弃用。这触发了类似问题中的警告,但仍允许代码在所有平台上编译和运行,而无需进行任何更改。
为了解决这个问题,运行时配备了模拟在平台上创建临时文件的代码,这些平台没有提供开箱即用的相应功能。现在,功能make_open_temporary
可在类FILE
的后代中创建。类FILE_NAME
被标记为过时,其代码已更新为使用新的运行时函数,从而避免了 C 编译器警告。因此,在 EiffelStudio 19.05及更高版本中没有警告。
相关文章:
- 既然存在危险,为什么项目要使用-I include开关
- 未初始化的变量有什么危险
- 将字符移出范围的危险
- 在C++的头文件中使用常量并在程序中询问其地址的任何潜在危险
- CRTP - 危险的内存访问?
- 危险指针的内存排序
- 在对象构造期间,将指向尚未构造的子对象的指针传递给另一个子对象的构造函数是否危险?
- 为什么 CWE 认为 rand() 具有潜在危险
- "this"关键字在C++中的实现限制,因为它与危险但功能示例有关
- 用于 Windows 写入临时文件的 mkstemp() 实现
- cppcheck 抱怨危险地使用 c_str(). c_str() 返回的值在此调用后无效
- cpp 检查抱怨危险使用 c_str(). c_str() 返回的值在本次调用后无效,如何解决?
- 使用危险的幻数N
- 派生类的模板类作为函数的参数 - 危险?
- CUDA:来自不同翘曲但相同块的 2 个线程尝试写入相同的共享内存位置:危险?
- 聚合初始化的 C++17 扩展是否使大括号初始化变得危险?
- 从 int 到 longlong 的危险转换:没有警告
- 在模板中存储右值引用的危险
- 这个危险指针示例是否因为 ABA 问题而存在缺陷?
- EiffelStudio 编译错误:使用 'tempnam' 很危险,最好使用 'mkstemp'