GreycLab / CImg

The CImg Library is a small and open-source C++ toolkit for image processing
http://cimg.eu
Other
1.48k stars 282 forks source link

Compilation warnings with clang14 (macOS Ventura) #371

Open dcoeurjo opened 1 year ago

dcoeurjo commented 1 year ago

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)

dtschump commented 1 year ago

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

dcoeurjo commented 1 year ago

πŸ‘ 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 commented 1 year ago

(and thx for the great lib BTW)

dtschump commented 1 year ago

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?

dcoeurjo commented 1 year ago

πŸ‘Œ 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...

dtschump commented 1 year ago

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

David.

dcoeurjo commented 1 year ago

πŸŽ‰πŸŽ‰thx