[bind10-dev] what to do for MSVC 4512 warnings?
Francis Dupont
fdupont at isc.org
Sun Jul 1 09:18:56 UTC 2012
The Microsoft Virtual Studio C++ compilers complain with the warning
4512 when a class (or struct) is declared with at least a const
member but no assignment constructor.
The Microsoft doc says:
You can resolve the C4512 warning for this code in one of three ways:
- Explicitly define an assignment operator for the class.
- Remove const from the data item in the class.
- Use the #pragma warning statement to suppress the warning.
I tried the first but it is very painful (a lot of spurious changes
in far too many files), the second is not available, the third works
well (I added a '#pragma warning(disable: 4512)' at the end of config.h)
but IMHO it is a bad idea to disable a warning by laziness (BTW there
is no way to disable a warning by compiler config/argument as it is
done, including in case it should not, for Unix compilers).
I propose a fourth way, IMHO far better: to make all impacted
class (and struct) declarations derived from boost::noncopyable
(BTW is it a real difference between:
class FooBar : boost::noncopyable { ... }
and
class FooBar : public boost::noncopyable { ... }
and which one should be used?)
Regards
Francis Dupont <fdupont at isc.org>
PS: if the noncopyable idea is adopted, I can give the list of classes
and structs.
More information about the bind10-dev
mailing list