The strcpy_s()
function is defined in TR 24731-1 (see Do you use the TR 24731 'safe' functions), and also in optional Annex K of ISO/IEC 9899:2011 (the C 2011 standard).
You can test whether your implementation supports it with:
__STDC_LIB_EXT1__
The integer constant 200509L, intended to indicate
conformance to this Technical Report.
(according to the TR). Annex K simply says:
An implementation that defines __STDC_LIB_EXT1__
shall conform to the
specifications in this annex.380)
380) Implementations that do not define __STDC_LIB_EXT1__
are not required to conform to these
specifications.
This answer indicates that the TC1 (Technical Corrigenda 1) for the C 2011 standard defines that __STDC_LIB_EXT1__
should be 201112L (Dec 2011) for the Annex K version of the functions. I've not tracked whether there are differences between Annex K and TR 24731-1.
So, you should be able to test whether your library supports strcpy_s()
by testing __STDC_LIB_EXT1__
, but it is optional. There was apparently a statement by Ulrich Drepper that the GNU C Library would not support the TR 24731-1 functions; I don't know whether that still holds.
Also, be aware that the Microsoft interfaces to some of these functions is different from the standard interfaces to the same function (vsnprintf_s()
, for example). That limits their usefulness as a cross-platform portability tool.