sprintf_s() implicit declaration warning
我有一个C代码,其中有此行。
1 | sprintf_s(var, outfile_ppm, local_filecounter++); |
在此,
当我运行代码时,它发出以下警告:
warning: implicit declaration of function 'sprintf_s' is invalid in C99 [-Wimplicit-function-declaration]
这是什么警告,我该如何消除它?
Despite more than a decade since the original proposal and nearly ten years since the ratification of ISO/IEC TR 24731-1:2007, and almost five years since the introduction of the Bounds checking interfaces into the C standard, no viable conforming implementations has emerged. The APIs continue to be controversial and requests for implementation continue to be rejected by implementers.
确实,如果您查看GCC C11状态页面,将会看到(强调):
Bounds-checking (Annex K) [Optional]: Library issue (not implemented)
附件K的唯一主要实现(
其他实现依赖于Valgrind,mudflap,地址清理器等工具来解决同一组问题,并且Microsoft之外很少有代码库实际使用这些功能,因此实现它们的动力很小。
换句话说,如果您不使用Visual Studio,则不能使用这些功能。幸运的是,它们不是必需的。
问题中对
1 2 | // Wait, what? Something smells fishy... sprintf_s(var, outfile_ppm, local_filecounter++); |
通常,您将使用
1 2 |
请注意,如果
摘要:除非切换到Visual Studio或自己实现,否则不能使用
次要说明:理论上,如果需要