FIX: fix current cmake warnings in linux and add support to treat warnings as errors in linux by gargsaumya · Pull Request #353 · microsoft/mssql-python
Work Item / Issue Reference
GitHub Issue: #<ISSUE_NUMBER>
Summary
This pull request introduces improvements to the build configuration and code safety for the mssql_python/pybind module. The main changes focus on enforcing stricter warning and error handling in the build system, improving cross-platform compatibility, and ensuring safe type casting in parameter binding.
Build system improvements:
- Enforced treating CMake warnings and deprecated features as errors by setting
CMAKE_ERROR_DEPRECATEDandCMAKE_WARN_DEPRECATEDtoTRUEinCMakeLists.txt, ensuring deprecated usage is caught early. - Added compiler warning flags for GCC and Clang (
-Werror,-Wattributes,-Wint-to-pointer-cast) to treat warnings as errors and catch visibility and type casting issues inCMakeLists.txt.
Code safety and compatibility:
- Suppressed visibility attribute warnings for the
ParamInfostruct on Linux using GCC diagnostic pragmas, while maintaining compatibility with Windows. [1] [2] - Updated type casting in the
BindParametersfunction to usereinterpret_castandstatic_castfor safe conversion of numeric precision and scale values toSQLPOINTER, preventing potential type safety issues.