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

AB#37803

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_DEPRECATED and CMAKE_WARN_DEPRECATED to TRUE in CMakeLists.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 in CMakeLists.txt.

Code safety and compatibility:

  • Suppressed visibility attribute warnings for the ParamInfo struct on Linux using GCC diagnostic pragmas, while maintaining compatibility with Windows. [1] [2]
  • Updated type casting in the BindParameters function to use reinterpret_cast and static_cast for safe conversion of numeric precision and scale values to SQLPOINTER, preventing potential type safety issues.