Macros are frequently used in the remediation of existing code to globally replace one identifier with another, for example, when an existing API changes. Although some risk is always involved, this practice becomes particularly dangerous if a function name is replaced with the function name of a deprecated or obsolescent function. Deprecated functions are defined by the C Standard and Technical Corrigenda. Obsolescent functions are defined by MSC34-C. Do not use deprecated or obsolete functions.
While Although compliance with rule MSC34-C. Do not use deprecated or obsolete functions guarantees compliance with this recommendation, the emphasis of this recommendation is the extremely risky and deceptive practice of replacing functions with less secure alternatives.
...
The solution is to include an implementation of the missing function vsnprintf()
to eliminate the dependency on external library functions when they are not available. This compliant solution assumes that __USE_ISOC11
is not defined on systems that fail to provide a vsnprintf()
implementation.:
Code Block | ||||
---|---|---|---|---|
| ||||
#include <stdio.h> #ifndef __USE_ISOC11 /* reimplements vsnprintf() */ #include "my_stdio.h" #endif |
...
[Open Group 2004] | vsnprintf() |
[Seacord 2013] | Chapter 6, "Formatted Output" |
[ISO/IEC 9899:2011] | Subclause 7.21.6.12 "The vsnprintf Function" |
[VU#654390] |
...