Page MenuHome

Fix deprecation warnings about printf() on macOS
ClosedPublic

Authored by Sergey Sharybin (sergey) on Nov 7 2022, 3:47 PM.

Details

Summary

The new Xcode 14.1 brings the new Apple Clang compiler which
considers sprintf unsafe and geenrates deprecation warnings
suggesting to sue snprintf instead. This only happens for C++
code by default, and C code can still use sprintf without any
warning.

This changes does the following:

  • Whenever is trivial replace sprintf() with BLI_snprintf.
  • For all other cases use the newly introduced BLI_sprintf which is a wrapper around sprintf() but without warning.

There is a discouragement note in the BLI_sprintf comment to
suggest use of BLI_snprintf when the size is known.

Diff Detail

Repository
rB Blender
Branch
sprintf (branched from master)
Build Status
Buildable 24517
Build 24517: arc lint + arc unit

Event Timeline

Sergey Sharybin (sergey) requested review of this revision.Nov 7 2022, 3:47 PM
Sergey Sharybin (sergey) created this revision.

I assume this will be committed to blender-v3.4-release? And maybe even backported to 3.3 and 2.93.

This revision is now accepted and ready to land.Nov 7 2022, 8:49 PM

This is where I am actually on a split. The patch is against the master branch, but it should be easy to apply to 3.4.
On one hand it is not really a fix, but on another hand it will help catching real issues in the compiler logs when working in the 3.4 branch. If you think it is safe and good for 3.4 lets do it!