mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Avoid C-style const casts (#659)
* Avoid C-style const casts Replace C-style casts that discard `const` with `const_cast` (and, where necessary, `reinterpret_cast` as well). * Warn about C-style const-discarding casts Change pybind11_enable_warnings to also enable `-Wcast-qual` (warn if a C-style cast discards `const`) by default. The previous commit should have gotten rid of all of these (at least, all the ones that tripped in my build, which included the tests), and this should discourage more from newly appearing.
This commit is contained in:
committed by
Wenzel Jakob
parent
d534bd670e
commit
e15fa9f99a
@@ -40,7 +40,7 @@ function(pybind11_enable_warnings target_name)
|
||||
if(MSVC)
|
||||
target_compile_options(${target_name} PRIVATE /W4)
|
||||
else()
|
||||
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wconversion)
|
||||
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wconversion -Wcast-qual)
|
||||
endif()
|
||||
|
||||
if(PYBIND11_WERROR)
|
||||
|
||||
Reference in New Issue
Block a user