0

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.

rivamarco
  • 719
  • 8
  • 23
  • 1
    It looks like this is a warning rather than an error, so there should be no issues. Can you run it? Or do you get another error when trying to execute it? – Alexander Kogtenkov Jan 18 '18 at 11:22
  • 1
    Possible duplicate of [tmpnam warning saying it is dangerous](https://stackoverflow.com/questions/3299881/tmpnam-warning-saying-it-is-dangerous) – Azeem Jan 18 '18 at 11:34
  • @AlexanderKogtenkov i get that error (it's not a warning, it tells me it is an error) if I try to run hello world. In another Windows 10 machine it works (i can see the Hello World message) doing the same steps to run it. – rivamarco Jan 18 '18 at 11:46
  • @Azeem yes but i don't know how to manage it because it's EiffelStudio – rivamarco Jan 18 '18 at 11:49
  • Steps: new project -> EiffelStudio will load a default hello world program -> Run button. In W10 works, in Arch i get the error – rivamarco Jan 18 '18 at 11:50
  • It's a bug in Eiffel Studio and/or its underlying Eiffel implementation. Complain to the vendor. – n. m. could be an AI Jan 18 '18 at 11:50
  • @rivamarco: You might want to look at your compile command for `Werror` swtich. It makes every warning into error. Take a look at the documentation: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html – Azeem Jan 18 '18 at 11:51
  • 1
    @Azeem (1) Eiffel Studio doesn't appear to have a way to modify C compilation flags. (2) This is a linker warning, not a compiler warning, and there is no way to silence those. – n. m. could be an AI Jan 18 '18 at 11:59
  • @n.m. so nothing to do. Thanks anyway. – rivamarco Jan 18 '18 at 12:12
  • I found that quite surprising what you said because I use EiffelStudio mainly on Linux Ubuntu and I get this Warning all the time. It does generate the executable binary and can be launched. Did you launch EiffelStudio from a terminal? Know that EiffelStudio spawn a terminal when you run a project on Windows but not on Linux. On Linux, everything that is print from your program will be printed in the same terminal that launched EiffelStudio. – Louis M Jan 18 '18 at 12:19
  • @LouisM damn it. I was launching it via KDE menu, so no terminal spawn :D Launching via terminal it's all ok despite the error, as you say. Solved. – rivamarco Jan 18 '18 at 12:25
  • @rivamarco Just for the record, you can add C compiler or linker flags in the project settings dialog: _Project_ | _Project Settings_ | _Target ..._ | _Advanced_ | _Externals_ | _Add C compiler/linker flag_. – Alexander Kogtenkov Jan 18 '18 at 12:52
  • I get it all the time too, EiffelStudio should be fixed. Problems like this probably allow an attacker to insert code that gets compiled into your binary. – Berend de Boer Jan 19 '18 at 07:27
  • PS: please edit your question so it says "tmpnam()", not tEmpnam(). – Berend de Boer Jan 19 '18 at 07:28

1 Answers1

0

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.

Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35