tmpnam warning saying it is dangerous

后端 未结 5 1074
醉话见心
醉话见心 2021-01-03 19:15

I get this warning saying that tmpnam is dangerous, but I would prefer to use it, since it can be used as is in Windows as well as Linux. I was wondering why it would be con

5条回答
  •  [愿得一人]
    2021-01-03 19:54

    if you speak about the compiler warning of MSVC:

     These functions are deprecated because more secure versions are available;
     see tmpnam_s, _wtmpnam_s.
    

    (http://msdn.microsoft.com/de-de/library/hs3e7355(VS.80).aspx)

    otherwise just read what the manpages say about the drawbacks of this function. it is mostly about a 2nd process creating exactly the same file name as your process just did.

提交回复
热议问题