On quarta-feira, 18 de dezembro de 2013 23:05:28, Nicolás Alvarez wrote: > 2013/12/18 Kurt Pattyn <pattyn.k...@gmail.com>: > > For a lot of the standard C functions, Microsoft has implemented "safe" > > versions. Functions like sprintf, scanf, strcpy, aso have "safe" > > counterparts with an _s suffix: sprintf_s, scanf_s, aso When the > > "non-safe" functions are used, the Microsoft compiler generates a warning > > that these functions should be replaced by their "safe" counterparts. > > There are 3 ways to get rid of these warnings: > > 1. replacing those functions, > > 2. using a #pragma > > 3. using a compiler flag > > > > What is the recommended way to get rid of these warnings in the Qt > > sources? > > > > I solved these warnings by replacing the calls with the safe versions, but > > the patch was rejected because it was recommended to use #pragmas. Before > > proceeding and going through the sources again, I would like to know the > > recommended practice within Qt. > The so-called safe functions with the _s are Microsoft extensions and > don't exist in other platforms. Changing to the "recommended" "safe" > functions makes the code only compile and work on Windows. > > I don't know how Qt handles this, but in other projects the solution > I've seen is to just define _CRT_SECURE_NO_WARNINGS globally.
I especially like memcpy_s, which takes an extra argument which is most often the exact same value you were already passing anyway[1]. Too bad they didn't make memcmp_s, that would have been funny, returning EDOOFUS if you passed the wrong args :-) [1] http://msdn.microsoft.com/en-us/library/wes2t00f.aspx [2] http://fxr.watson.org/fxr/ident?i=EDOOFUS See also the suggested replacements at [3], of which I like EEEEEEEEEEK best [3] https://groups.google.com/forum/?hl=en#!msg/fa.freebsd.hackers/V7cWmQeWVfg/IIjCCbdz4BEJ -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development