CImg icon indicating copy to clipboard operation
CImg copied to clipboard

Compilation warnings with clang14 (macOS Ventura)

Open dcoeurjo opened this issue 1 year ago β€’ 7 comments

When using the current release CImg-3.2.0_pre110222/CImg.h, I'm having a lot of warnings (mostly depreciation on vspintf usage and implicit conversions that lose precision).

Is there a way to globally disable CImg.h warnings when used in another project ?

Would you be interested in having the list of warnings I get ?

(clang 14, default compiler on macOS Ventura)

dcoeurjo avatar Dec 16 '22 10:12 dcoeurjo

Yes, definitely interested by the log. I don't compile CImg often with clang, but I think I'll have to try again :)

dtschump avatar Dec 16 '22 10:12 dtschump

πŸ‘ the vsprintf one:

In file included from /Users/davidcoeurjolly/Projects/utk/src/integration/IntegrationGaussian_fromfile_2dd.cpp:41:
/Users/davidcoeurjolly/Projects/utk/src/integration/../../externals/CImg-3.2.0_pre110222/CImg.h:2422:31: warning: 'vsprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use vsnprintf(3) instead. [-Wdeprecated-declarations]
      const int result = std::vsprintf(s,format,args);
                              ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/stdio.h:207:1: note: 'vsprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use vsnprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^

For the implicit conversions: https://gist.github.com/dcoeurjo/19276902333affb1a9ca7f701eb7764e

dcoeurjo avatar Dec 16 '22 11:12 dcoeurjo

(and thx for the great lib BTW)

dcoeurjo avatar Dec 16 '22 11:12 dcoeurjo

David, I've just installed clang-12 but cannot get the same warning. If you replace the problematic line by:

      const int result = std::vsnprintf(s,(size_t)~0U,format,args);

do you still get a warning ?

EDIT: Installed clang-14 on a VM (Ubuntu 22.04) and still don't get your warning. Maybe a MacOSX-specific stuff?

dtschump avatar Dec 16 '22 12:12 dtschump

πŸ‘Œ for the vspnrintf thing, no more warning. Thx

For clang14, I agree that with default settings, the implicit conversion warnings are not raised. When used in Xcode or the xcodebuild command line, extra warning flags seem to be added and I've got the trace I sent you.

Let me try to get the build parameters Xcode is using...

dcoeurjo avatar Dec 16 '22 13:12 dcoeurjo

FYI, I've posted a new .zip archive on the main website, with the fix included. Cheers.

David.

dtschump avatar Dec 16 '22 17:12 dtschump

πŸŽ‰πŸŽ‰thx

dcoeurjo avatar Dec 16 '22 17:12 dcoeurjo