CMakeLists: Make most implicit type conversion warnings errors on MSVC
Quite frequently there have been cases where code has been merged into the core that produces warning. In order to prevent this from occurring, we can make the compiler flag these cases and allow our CI to flag down any code that would generate these warnings. This is beneficial given silent conversions from signed/unsigned can result in logic bugs. This forces one writing changes to be explicit about when signedness conversions are desirable, rather than leaving it up to readers' interpretation. Currently the codebase isn't in a state where it will build successfully with this change applied, but this will be addressed in subsequent follow-up changes. This set of changes will focus on making it build properly with these changes for MSVC as a starting point for basic coverage.
This commit is contained in:
parent
8714d40a77
commit
96d677bef0
|
@ -522,6 +522,23 @@ add_library(core STATIC
|
|||
tools/freezer.h
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(core PRIVATE
|
||||
# 'expression' : signed/unsigned mismatch
|
||||
/we4018
|
||||
# 'argument' : conversion from 'type1' to 'type2', possible loss of data (floating-point)
|
||||
/we4244
|
||||
# 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
|
||||
/we4245
|
||||
# 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
|
||||
/we4254
|
||||
# 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||
/we4267
|
||||
# 'context' : truncation from 'type1' to 'type2'
|
||||
/we4305
|
||||
)
|
||||
endif()
|
||||
|
||||
create_target_directory_groups(core)
|
||||
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core video_core)
|
||||
|
|
Reference in New Issue