So I know I can turn warnings into errors using -Werror=… but I want to make the following warning into an error:
“Class xxx has virtual functions but non-virtual destructor”
The only way I know you can get this error is by turning on the overly obnoxious -Weffc++ flag. Is there a way (or what is the sub-flag in -Weffc++ for this warning) to just print this warning and then turn it into an error?
Thanks!
-Wnon-virtual-dtoris the name of the specific warning that is turned on by-Weffc++. To turn any warning into an error, you use-Werror=.... So if the warning were-Wspam, making it into an error would be-Werror=spam. So in this case, you would use-Werror=non-virtual-dtor.However, I don’t feel that this warning is especially useful if you are on GCC 4.8 and up. Then you have access to the superior
-Wdelete-non-virtual-dtor:Note that
g++ -Wspam -Werror=spamis the same thing asg++ -Werror=spam. Turning a warning into an error automatically turns that warning on.On a related note, you’re not the only one who thinks that
-Weffc++is a little overzealous.