Author Topic: [solved] the use of `tmpnam' is dangerous, better use `mkstemp'  (Read 48982 times)

Offline danieru

  • Single posting newcomer
  • *
  • Posts: 5
When trying to compile any C++ project that uses tmpnam it gives an error saying " the use of `tmpnam' is dangerous, better use `mkstemp' ".
I read that using the option -Wno-deprecated-declarations should work, but it didn't work for me.

I think the mistake is that I'm not writing -Wno-deprecated-declarations where it should. So if someone could tell me where I should write -Wno-deprecated-declarations would be very helpful.
« Last Edit: April 25, 2014, 09:07:48 pm by danieru »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #1 on: April 25, 2014, 02:57:30 am »
This is not a question related to C::B. Please find a place you can get the correct answer.
Please respect our forum rules. Thank you.
See: FAQ


EDIT:
As stahta01 said, you can put GCC build options there.
« Last Edit: April 25, 2014, 04:11:38 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #2 on: April 25, 2014, 03:42:52 am »
My guess of the CB location is this:

"Project" -> "Build Options..."
Tab "Compiler Settings"
Sub-Tab "Other Options"

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline danieru

  • Single posting newcomer
  • *
  • Posts: 5
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #3 on: April 25, 2014, 06:46:58 pm »
My guess of the CB location is this:

"Project" -> "Build Options..."
Tab "Compiler Settings"
Sub-Tab "Other Options"

Tim S.

Thank you! now I can be sure it is in the right place. But the error message still appears. Even so the message "the use of` tmpnam 'is dangerous, better use `mkstemp'" should be only a warning and not an error. right?

What makes me think that maybe CB is interpreting it as an error.

Offline danieru

  • Single posting newcomer
  • *
  • Posts: 5
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #4 on: April 25, 2014, 07:09:07 pm »
maybe a screenshot help

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #6 on: April 25, 2014, 07:49:32 pm »
maybe a screenshot help

No it doesn't. Post the Build log containing the full commandline and error message.

Offline danieru

  • Single posting newcomer
  • *
  • Posts: 5
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #7 on: April 25, 2014, 08:05:58 pm »
maybe a screenshot help

No it doesn't. Post the Build log containing the full commandline and error message.

Build log:
Code

-------------- Clean: Debug in test (compiler: GNU GCC Compiler)---------------

Cleaned "test - Debug"

-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------

g++ -w -fexceptions -msse3 -Wno-deprecated-declarations -DDG_DISABLE_ASSERT -DZLIB -DPLATFORM_LINUX -D_NEWTON_STATIC_LIB -DFT2_BUILD_LIBRARY -DOPENGL -Dunix -D_POSIX_VER -D_POSIX_VER_64 -DDG_THREAD_EMULATION -D_STATICLIB -DDG_USE_THREAD_EMULATION -DGL_GLEXT_PROTOTYPES -DLEADWERKS_3_1 -D_CUSTOM_JOINTS_STATIC_LIB -w -g -Wno-deprecated-declarations -DDEBUG -D_DEBUG -std=c++11 -Wno-deprecated-declarations -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/core -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/meshUtil -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/newton -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/physics -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/packages/dMath -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/packages/dContainers -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/packages/dCustomJoints -I"/home/brandd/Leadwerks"/Include/Libraries/tolua++-1.0.93/include -I"/home/brandd/Leadwerks"/Include/Libraries/lua-5.1.4 -I"/home/brandd/Leadwerks"/Include/Libraries/freetype-2.4.7/include -I"/home/brandd/Leadwerks"/Include/Libraries/enet-1.3.1/include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/DebugUtils/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/Detour/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/DetourCrowd/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/DetourTileCache/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/Recast/Include -I"/home/brandd/Leadwerks"/Include -I"/home/brandd/Leadwerks"/Include/Libraries/zlib-1.2.5 -I"/home/brandd/Leadwerks"/Include/Libraries/zlib-1.2.5/contrib/minizip -I"/home/brandd/Leadwerks"/Include/Libraries/freetype-2.4.7/include/freetype -I"/home/brandd/Leadwerks"/Include/Libraries/freetype-2.4.7/include/freetype/config -I"/home/brandd/Leadwerks"/Include/Libraries/LuaJIT/dynasm -I"/home/brandd/Leadwerks"/Include/Libraries/glew-1.6.0/include -c /home/brandd/Documents/Leadwerks/Projects/test/Source/App.cpp -o ../../Source/App.o
g++ -w -fexceptions -msse3 -Wno-deprecated-declarations -DDG_DISABLE_ASSERT -DZLIB -DPLATFORM_LINUX -D_NEWTON_STATIC_LIB -DFT2_BUILD_LIBRARY -DOPENGL -Dunix -D_POSIX_VER -D_POSIX_VER_64 -DDG_THREAD_EMULATION -D_STATICLIB -DDG_USE_THREAD_EMULATION -DGL_GLEXT_PROTOTYPES -DLEADWERKS_3_1 -D_CUSTOM_JOINTS_STATIC_LIB -w -g -Wno-deprecated-declarations -DDEBUG -D_DEBUG -std=c++11 -Wno-deprecated-declarations -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/core -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/meshUtil -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/newton -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/coreLibrary_300/source/physics -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/packages/dMath -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/packages/dContainers -I"/home/brandd/Leadwerks"/Include/Libraries/NewtonDynamics/packages/dCustomJoints -I"/home/brandd/Leadwerks"/Include/Libraries/tolua++-1.0.93/include -I"/home/brandd/Leadwerks"/Include/Libraries/lua-5.1.4 -I"/home/brandd/Leadwerks"/Include/Libraries/freetype-2.4.7/include -I"/home/brandd/Leadwerks"/Include/Libraries/enet-1.3.1/include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/DebugUtils/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/Detour/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/DetourCrowd/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/DetourTileCache/Include -I"/home/brandd/Leadwerks"/Include/Libraries/RecastNavigation/Recast/Include -I"/home/brandd/Leadwerks"/Include -I"/home/brandd/Leadwerks"/Include/Libraries/zlib-1.2.5 -I"/home/brandd/Leadwerks"/Include/Libraries/zlib-1.2.5/contrib/minizip -I"/home/brandd/Leadwerks"/Include/Libraries/freetype-2.4.7/include/freetype -I"/home/brandd/Leadwerks"/Include/Libraries/freetype-2.4.7/include/freetype/config -I"/home/brandd/Leadwerks"/Include/Libraries/LuaJIT/dynasm -I"/home/brandd/Leadwerks"/Include/Libraries/glew-1.6.0/include -c /home/brandd/Documents/Leadwerks/Projects/test/Source/main.cpp -o ../../Source/main.o
g++  -o ../../test.debug ../../Source/App.o ../../Source/main.o  -Wno-deprecated-declarations -Wno-deprecated-declarations -Wno-deprecated-declarations  ""/home/brandd/Leadwerks"/Library/Linux/Debug/Leadwerks.a" -lopenal -lGL -lGLU ""/home/brandd/Leadwerks"/Library/Linux/libluajit.a"
/home/brandd/Leadwerks/Library/Linux/Debug/Leadwerks.a(loslib.o): En la función `os_tmpname':
/home/josh/Leadwerks/Engine/Source/Libraries/lua-5.1.4/loslib.c:60: aviso: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/bin/ld: /home/brandd/Leadwerks/Library/Linux/Debug/Leadwerks.a(Thread.o): referencia sin definir al símbolo 'pthread_create@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 8 second(s))
1 error(s), 0 warning(s) (0 minute(s), 8 second(s))
 

the error is on this file: http://www.lua.org/source/5.2/loslib.c.html on line 60.
« Last Edit: April 25, 2014, 08:07:35 pm by danieru »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #8 on: April 25, 2014, 08:20:52 pm »
If you use localized gcc, you need to fix the regexes C::B uses to parse the messages (and decide, whether it's an error or watning or whatever).
But this can be carefull, in general it's better to use english output only:
How can I change the language of the compiler (gcc) output to english?

Offline danieru

  • Single posting newcomer
  • *
  • Posts: 5
Re: the use of `tmpnam' is dangerous, better use `mkstemp'
« Reply #9 on: April 25, 2014, 09:06:47 pm »
If you use localized gcc, you need to fix the regexes C::B uses to parse the messages (and decide, whether it's an error or watning or whatever).
But this can be carefull, in general it's better to use english output only:
How can I change the language of the compiler (gcc) output to english?

Thank you! That solves my problem, now "the use of` tmpnam 'is dangerous, better use `mkstemp'" is just a warning.  :D