Skip to content

Commit 79706c7

Browse files
authored
Merge branch 'main' into jahnvi/250_encoding_decoding
2 parents 4ad47ca + a896a93 commit 79706c7

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

mssql_python/pybind/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
88
# Enable verbose output to see actual compiler/linker commands
99
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose output" FORCE)
1010

11+
# Treat CMake warnings as errors
12+
set(CMAKE_ERROR_DEPRECATED TRUE)
13+
set(CMAKE_WARN_DEPRECATED TRUE)
14+
1115
if (MSVC)
1216
# Security compiler options for OneBranch compliance
1317
message(STATUS "Applying MSVC security compiler options for OneBranch compliance")
@@ -302,6 +306,21 @@ if(MSVC)
302306
target_compile_options(ddbc_bindings PRIVATE /W4 /WX)
303307
endif()
304308

309+
# Add warning flags for GCC/Clang on Linux and macOS
310+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
311+
target_compile_options(ddbc_bindings PRIVATE
312+
-Werror # Treat warnings as errors
313+
-Wattributes # Enable attribute warnings (cross-compiler)
314+
)
315+
316+
# GCC-specific warning flags
317+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
318+
target_compile_options(ddbc_bindings PRIVATE
319+
-Wint-to-pointer-cast # GCC-specific warning for integer-to-pointer casts
320+
)
321+
endif()
322+
endif()
323+
305324
# Add macOS-specific string conversion fix
306325
if(APPLE)
307326
message(STATUS "Enabling macOS string conversion fix")

mssql_python/pybind/ddbc_bindings.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ py::object get_uuid_class() {
114114

115115
// Struct to hold parameter information for binding. Used by SQLBindParameter.
116116
// This struct is shared between C++ & Python code.
117+
// Suppress -Wattributes warning for ParamInfo struct
118+
// The warning is triggered because pybind11 handles visibility attributes automatically,
119+
// and having additional attributes on the struct can cause conflicts on Linux with GCC
120+
#ifdef __GNUC__
121+
#pragma GCC diagnostic push
122+
#pragma GCC diagnostic ignored "-Wattributes"
123+
#endif
117124
struct ParamInfo {
118125
SQLSMALLINT inputOutputType;
119126
SQLSMALLINT paramCType;
@@ -124,6 +131,9 @@ struct ParamInfo {
124131
bool isDAE = false; // Indicates if we need to stream
125132
py::object dataPtr;
126133
};
134+
#ifdef __GNUC__
135+
#pragma GCC diagnostic pop
136+
#endif
127137

128138
// Mirrors the SQL_NUMERIC_STRUCT. But redefined to replace val char array
129139
// with std::string, because pybind doesn't allow binding char array.
@@ -748,23 +758,23 @@ SQLRETURN BindParameters(SQLHANDLE hStmt, const py::list& params,
748758
}
749759
SQL_NUMERIC_STRUCT* numericPtr = reinterpret_cast<SQL_NUMERIC_STRUCT*>(dataPtr);
750760
rc = SQLSetDescField_ptr(hDesc, 1, SQL_DESC_PRECISION,
751-
(SQLPOINTER)numericPtr->precision, 0);
761+
reinterpret_cast<SQLPOINTER>(static_cast<uintptr_t>(numericPtr->precision)), 0);
752762
if (!SQL_SUCCEEDED(rc)) {
753763
LOG("BindParameters: SQLSetDescField(SQL_DESC_PRECISION) "
754764
"failed for param[%d] - SQLRETURN=%d",
755765
paramIndex, rc);
756766
return rc;
757767
}
758768

759-
rc = SQLSetDescField_ptr(hDesc, 1, SQL_DESC_SCALE, (SQLPOINTER)numericPtr->scale, 0);
769+
rc = SQLSetDescField_ptr(hDesc, 1, SQL_DESC_SCALE, reinterpret_cast<SQLPOINTER>(static_cast<intptr_t>(numericPtr->scale)), 0);
760770
if (!SQL_SUCCEEDED(rc)) {
761771
LOG("BindParameters: SQLSetDescField(SQL_DESC_SCALE) failed "
762772
"for param[%d] - SQLRETURN=%d",
763773
paramIndex, rc);
764774
return rc;
765775
}
766776

767-
rc = SQLSetDescField_ptr(hDesc, 1, SQL_DESC_DATA_PTR, (SQLPOINTER)numericPtr, 0);
777+
rc = SQLSetDescField_ptr(hDesc, 1, SQL_DESC_DATA_PTR, reinterpret_cast<SQLPOINTER>(numericPtr), 0);
768778
if (!SQL_SUCCEEDED(rc)) {
769779
LOG("BindParameters: SQLSetDescField(SQL_DESC_DATA_PTR) failed "
770780
"for param[%d] - SQLRETURN=%d",

0 commit comments

Comments
 (0)