Results 1 to 2 of 2

Thread: Using the stdio_s.h in Qt

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Using the stdio_s.h in Qt

    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
    Qt Code:
    1. C:\Qt\Qt5.3.1\Tools\mingw482_32\i686-w64-mingw32\include\sec_api\stdio_s.h
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. #include <sec_api/stdio_s.h>
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using the stdio_s.h in Qt

    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).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    feraudyh (6th September 2017)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.