Commit a896a93
authored
FIX: fix current cmake warnings in linux and add support to treat warnings as errors in linux (#353)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#37803](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/37803)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
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]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R117-R121)
[[2]](diffhunk://#diff-dde2297345718ec449a14e7dff91b7bb2342b008ecc071f562233646d71144a1R132-R134)
* 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.
<!--
### PR Title Guide
> For feature requests
FEAT: (short-description)
> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description)
> For Fix requests
FIX: (short-description)
> For doc update requests
DOC: (short-description)
> For Formatting, indentation, or styling update
STYLE: (short-description)
> For Refactor, without any feature changes
REFACTOR: (short-description)
> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description)
### Contribution Guidelines
External contributors:
- Create a GitHub issue first:
https://github.com/microsoft/mssql-python/issues/new
- Link the GitHub issue in the "GitHub Issue" section above
- Follow the PR title format and provide a meaningful summary
mssql-python maintainers:
- Create an ADO Work Item following internal processes
- Link the ADO Work Item in the "ADO Work Item" section above
- Follow the PR title format and provide a meaningful summary
-->1 parent 4d2634a commit a896a93
2 files changed
+32
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
302 | 306 | | |
303 | 307 | | |
304 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
305 | 324 | | |
306 | 325 | | |
307 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
117 | 124 | | |
118 | 125 | | |
119 | 126 | | |
| |||
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
| |||
713 | 723 | | |
714 | 724 | | |
715 | 725 | | |
716 | | - | |
| 726 | + | |
717 | 727 | | |
718 | 728 | | |
719 | 729 | | |
720 | 730 | | |
721 | 731 | | |
722 | 732 | | |
723 | 733 | | |
724 | | - | |
| 734 | + | |
725 | 735 | | |
726 | 736 | | |
727 | 737 | | |
728 | 738 | | |
729 | 739 | | |
730 | 740 | | |
731 | 741 | | |
732 | | - | |
| 742 | + | |
733 | 743 | | |
734 | 744 | | |
735 | 745 | | |
| |||
0 commit comments