PDA

View Full Version : Using the stdio_s.h in Qt



feraudyh
28th August 2017, 16:22
I want to use a secure version of sprintf.
Microsoft's Visual Studio suggests that I use sprintf_s instead.

In my case, however I want to develop in QtCreator with mingw.
My Windows installation contains a file called stdio_s.h. It's installed in

C:\Qt\Qt5.3.1\Tools\mingw482_32\i686-w64-mingw32\include\sec_api\stdio_s.h
If I type
#include <stdio_s.h>
the QtCreator environment underlines it in green, the usual way of indicating that this is not defined.
Yet the same environment got me to stdio_s.h when I typed sprintf_s and chose "Follow Symbol Under Cursor" with the right-click popup menu.
Things go better if I type

#include <sec_api/stdio_s.h>

Is this version of sprintf_s very similar to the one provided by Microsoft?

wysota
28th August 2017, 16:40
It's a standard C11 call so if your compiler is C11-compatible, the function should work as defined in the standard (http://en.cppreference.com/w/c/io/fprintf).