EiffelStudio compile error: The use of `tempnam' is dangerous, better use `mkstemp'

726 Views Asked by At

I'm using eiffelstudio-bin 17.05.100416-1 installed via AUR in Arch.

When I try to run the default hello world project, i have this error in the Error List tab:

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' 

And in the Output tab, under External Compilations:

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

And obviusly, hello world program doesn't work.

I'm using gcc 7.2.1+20171224-2, if it's useful.

What can i do?

Thanks in advance.

1

There are 1 best solutions below

0
Alexander Kogtenkov On

What was not working?

According to the comments, the warning did not preclude the program from running as expected. However, the program was launched without terminal and its output was not visible.

Why did I get the warning?

The code of the standard library is cross-platform. Whereas, some platforms provide both functions — one to create a temporary file and another to build a temporary file name — others provide only the second one. Eiffel code supported only the function available on all platforms, i.e. the function to build a temporary file name. At some point, the function on the first set of platforms was marked as deprecated. This triggered warnings like the one in the question, but still allowed code to compile and run without any change on all platforms.

In order to address this issue, the run-time was equipped with the code emulating creation of temporary files on platforms that did not provide the corresponding functions out of the box. Now, feature make_open_temporary is available for creation in descendants of class FILE. Class FILE_NAME was marked as obsolete, and its code was updated to use the new run-time function, thus avoiding the C compiler warning. As a result, there is no warning in EiffelStudio 19.05 and above.