Re: [Lcms-user] Build warnings on OSX / clang
An ICC-based CMM for color management
Brought to you by:
mm2
From: Noel C. <NCa...@Pr...> - 2017-07-24 20:49:00
|
Hello all, Compiler warnings are available to show us where programmers have taken liberties with the language, but have not acknowledged those liberties (via a cast). IMO, the C language implicit integer assignment rules were a shortcoming of the language, leading to sloppy work, not a feature. In our projects all our code builds clean with Visual Studio's max warning level (-Wall) and Code Analysis. We don't allow warnings to persist, and I honestly don't know why - other than economics - anyone would want to set a project up to use anything less. I don't mean to be critical of Marti's code - it's very good overall and emits no warnings with Visual Studio 2017 on level 4 (which is better than most source projects), but it DOES gather hundreds of warnings when set to -Wall, many of which are of the form: ..\..\..\src\cmsgamma.c(143): warning C4365: '=': conversion from 'cmsUInt32Number' to 'int', signed/unsigned mismatch Unfortunately, it really IS a coding error to expect an unsigned integer to fit implicitly into a signed integer. If you "just know" that there can be no sign problems, then the code should reflect that. The right solution is not to add casts, but rather to change the code so that the data types DO match one another - or in a pinch use explicit casts in the code (with appropriate comments) indicating that the disparity has been noted and is expected and okay. In the specific case identified (an unsigned 32 bit number being copied to a signed 32 bit value) we can't know, without careful analysis of the code, whether there can be (now, or in the future) a negative number or positive 32 bit number larger than 2^31 passed around. That's a gotcha that should not be left in. If types have to change, of course it's necessary to work out the problems each code change could cause. That's the cost of creating truly good code. The upside is that when it's done the code can be consistently compiled with the highest warning level, which helps keep errors from creeping in during ongoing development. Marti, I'm willing to take a look at reducing the warning count if you're willing to entertain putting the changes back into your sources (as you have done in the past). -Noel Carboni ProDigital Software |