the use of `tempnam' is dangerous
| hasmik (5) |
|
Hi all.
I have a C++ code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <stdio.h>
int main ()
{
char n1 [L_tmpnam];
char * n2;
tmpnam (n1);
printf ("Tempname #1: %s\n",n1);
n2 = tmpnam (NULL);
printf ("Tempname #2: %s\n",n2);
return 0;
}
|
I compiled it with this command:
g++ tmpnam.cc
and got this warning:
/tmp/cc6NCfHE.o: In function `main':
tmpnam.cc:(.text+0x18): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
|
| Can anyone help me to understand the reason of this warning? |
Thanks,
Hasmik.
|
|
|
| hasmik (5) |
|
Hi,
Thanks for advice.
| I have read it, and now i want to know is there a way to disable this warning? |
Regards,
Hasmik.
|
|
Last edited on
|
| choisum (97) |
|
g++ tmpnam.cc 2>&1 | grep -v "'tmpnam' is dangerous" :)
otherwise, there may be a compiler directive (e.g. #pragma) somewhere...
Pretty sure I did this for some other annoying warning in g++.
|
|
Last edited on
|
| hasmik (5) |
|
|
Thanks for help.
|
|
|
Topic archived. No new replies allowed.