Skip to content

GH-46576: [C++] Suppress codecvt_utf8 deprecation warning#46622

Merged
kou merged 2 commits intoapache:mainfrom
Bit-Quill:GH-46576
May 30, 2025
Merged

GH-46576: [C++] Suppress codecvt_utf8 deprecation warning#46622
kou merged 2 commits intoapache:mainfrom
Bit-Quill:GH-46576

Conversation

@alinaliBQ
Copy link
Collaborator

@alinaliBQ alinaliBQ commented May 27, 2025

Rationale for this change

Resolve warnings that get treated as errors by suppressing the warning.

What changes are included in this PR?

  1. Add ARROW_SUPPRESS_DEPRECATION_WARNING to code that use codecvt_utf8
  2. Add explicit conversions for integer values in cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h

Are these changes tested?

They are tested locally on my Windows environment. The build succeeds.

Are there any user-facing changes?

None

@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

1 similar comment
@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels May 27, 2025
@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

@hiroyuki-sato
Copy link
Collaborator

hiroyuki-sato commented May 28, 2025

Hello, @alinaliBQ

macOS (14.7.1) clang(Apple clang version 16.0.0) doesn't match __GNUC__ >= 11.
So you need additional check

P.S.
clang returns true #ifdef __GNUC__.
So, #if defined(__GNUC__) || defined(__clang__) should be #if defined(__GNUC__).
(I don't familiar with compiler pragma)

#ifdef __GNUC__
#  warning "__GNUC__ is defined"
#endif
#ifdef __clang__
#  warning "__clang__ is defined"
#endif

#if __GNUC__ >= 11
  warning "clang return true __GNU__ >= 11"
#else
  warning "clang return false __GNU__ >= 11"
#endif
test.c:2:4: warning: "__GNUC__ is defined" [-W#warnings]
    2 | #  warning "__GNUC__ is defined"
      |    ^
test.c:5:4: warning: "__clang__ is defined" [-W#warnings]
    5 | #  warning "__clang__ is defined"
      |    ^
test.c:11:3: error: unknown type name 'warning'
   11 |   warning "clang return false __GNU__ >= 11"
      |   ^
test.c:11:11: error: expected identifier or '('
   11 |   warning "clang return false __GNU__ >= 11"
      |           ^
2 warnings and 2 errors generated.

This patch will fix encoding.h part, but It seems you need some additional works.

diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h
index bd7ead678a..28883675d6 100644
--- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h
+++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h
@@ -80,6 +80,9 @@ namespace odbcabstraction {
 #if defined(__GNUC__)
 #  pragma GCC diagnostic push
 #  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#elif defined(__clang__)
+#  pragma clang diagnostic push
+#  pragma clang diagnostic ignored "-Wdeprecated-declarations"
 #endif
 template <typename CHAR_TYPE>
 inline void Utf8ToWcs(const char* utf8_string, size_t length,
@@ -93,7 +96,7 @@ inline void Utf8ToWcs(const char* utf8_string, size_t length,
   result->reserve(length_in_bytes);
   result->assign(data, data + length_in_bytes);
 }
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
 #  pragma GCC diagnostic pop
 #endif

@@ -118,6 +121,9 @@ inline void Utf8ToWcs(const char* utf8_string, std::vector<uint8_t>* result) {
 #if defined(__GNUC__) && __GNUC__ >= 11
 #  pragma GCC diagnostic push
 #  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#elif defined(__clang__)
+#  pragma clang diagnostic push
+#  pragma clang diagnostic ignored "-Wdeprecated-declarations"
 #endif
 template <typename CHAR_TYPE>
 inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units,
@@ -132,7 +138,7 @@ inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units,
   result->reserve(length_in_bytes);
   result->assign(data, data + length_in_bytes);
 }
-#if defined(__GNUC__) && __GNUC__ >= 11
+#if (defined(__GNUC__) && __GNUC__ >= 11) || defined(__clang__)
 #  pragma GCC diagnostic pop
 #endif
/opt/homebrew/bin/ccache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DARROW_HAVE_NEON -DARROW_WITH_TIMING_TESTS -DFMT_HEADER_ONLY -DGRPC_ENABLE_ASYNC -DGRPC_NAMESPACE_FOR_TLS_CREDENTIALS_OPTIONS=grpc::experimental -DGRPC_USE_CERTIFICATE_VERIFIER -DGRPC_USE_TLS_CHANNEL_CREDENTIALS_OPTIONS -I/path/to/arrow/cpp/build/src -I/path/to/arrow/cpp/src -I/path/to/arrow/cpp/src/generated -I/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include -I/path/to/arrow/cpp/build/_deps/spdlog-src/include -isystem /opt/homebrew/include -fno-aligned-new  -Qunused-arguments -fcolor-diagnostics  -Wall -Wextra -Wdocumentation -DARROW_WARN_DOCUMENTATION -Wshorten-64-to-32 -Wno-missing-braces -Wno-unused-parameter -Wno-constant-logical-operand -Wno-return-stack-address -Wdate-time -Wno-unknown-warning-option -Wno-pass-failed -march=armv8-a  -g -Werror -O0 -ggdb  -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fPIC -MD -MT src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/__/__/__/__/vendored/whereami/whereami.cc.o -MF src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/__/__/__/__/vendored/whereami/whereami.cc.o.d -o src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/__/__/__/__/vendored/whereami/whereami.cc.o -c /path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:337:16: error: use of undeclared identifier 'PATH_MAX'
  337 |   char buffer1[PATH_MAX];
      |                ^
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:338:16: error: use of undeclared identifier 'PATH_MAX'
  338 |   char buffer2[PATH_MAX];
      |                ^
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:354:19: error: use of undeclared identifier 'strlen'
  354 |     length = (int)strlen(resolved);
      |                   ^
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:356:7: error: use of undeclared identifier 'memcpy'
  356 |       memcpy(out, resolved, length);
      |       ^
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:378:15: error: use of undeclared identifier 'PATH_MAX'
  378 |   char buffer[PATH_MAX];
      |               ^
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:389:21: error: use of undeclared identifier 'strlen'
  389 |       length = (int)strlen(resolved);
      |                     ^
/path/to/arrow/cpp/src/arrow/vendored/whereami/whereami.cc:391:9: error: use of undeclared identifier 'memcpy'
  391 |         memcpy(out, resolved, length);
      |         ^
7 errors generated.
[3/619] Building CXX object src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_descriptor.cc.o
FAILED: src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_descriptor.cc.o
/opt/homebrew/bin/ccache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DARROW_HAVE_NEON -DARROW_WITH_TIMING_TESTS -DFMT_HEADER_ONLY -DGRPC_ENABLE_ASYNC -DGRPC_NAMESPACE_FOR_TLS_CREDENTIALS_OPTIONS=grpc::experimental -DGRPC_USE_CERTIFICATE_VERIFIER -DGRPC_USE_TLS_CHANNEL_CREDENTIALS_OPTIONS -I/path/to/arrow/cpp/build/src -I/path/to/arrow/cpp/src -I/path/to/arrow/cpp/src/generated -I/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include -I/path/to/arrow/cpp/build/_deps/spdlog-src/include -isystem /opt/homebrew/include -fno-aligned-new  -Qunused-arguments -fcolor-diagnostics  -Wall -Wextra -Wdocumentation -DARROW_WARN_DOCUMENTATION -Wshorten-64-to-32 -Wno-missing-braces -Wno-unused-parameter -Wno-constant-logical-operand -Wno-return-stack-address -Wdate-time -Wno-unknown-warning-option -Wno-pass-failed -march=armv8-a  -g -Werror -O0 -ggdb  -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fPIC -MD -MT src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_descriptor.cc.o -MF src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_descriptor.cc.o.d -o src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_descriptor.cc.o -c /path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:157:20: error: comparison of integers of different signs: 'SQLSMALLINT' (aka 'short') and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
  157 |   if (recordNumber > m_records.size()) {
      |       ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:308:20: error: comparison of integers of different signs: 'SQLSMALLINT' (aka 'short') and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
  308 |   if (recordNumber > m_records.size()) {
      |       ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:480:61: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  480 |     m_records[i].m_baseColumnName = rsmd->GetBaseColumnName(oneBasedIndex);
      |                                           ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:481:59: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  481 |     m_records[i].m_baseTableName = rsmd->GetBaseTableName(oneBasedIndex);
      |                                          ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:482:55: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  482 |     m_records[i].m_catalogName = rsmd->GetCatalogName(oneBasedIndex);
      |                                        ~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:483:49: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  483 |     m_records[i].m_label = rsmd->GetColumnLabel(oneBasedIndex);
      |                                  ~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:484:59: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  484 |     m_records[i].m_literalPrefix = rsmd->GetLiteralPrefix(oneBasedIndex);
      |                                          ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:485:59: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  485 |     m_records[i].m_literalSuffix = rsmd->GetLiteralSuffix(oneBasedIndex);
      |                                          ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:486:59: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  486 |     m_records[i].m_localTypeName = rsmd->GetLocalTypeName(oneBasedIndex);
      |                                          ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:487:41: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  487 |     m_records[i].m_name = rsmd->GetName(oneBasedIndex);
      |                                 ~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:488:53: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  488 |     m_records[i].m_schemaName = rsmd->GetSchemaName(oneBasedIndex);
      |                                       ~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:489:51: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  489 |     m_records[i].m_tableName = rsmd->GetTableName(oneBasedIndex);
      |                                      ~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:490:49: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  490 |     m_records[i].m_typeName = rsmd->GetTypeName(oneBasedIndex);
      |                                     ~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:492:55: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  492 |         GetSqlTypeForODBCVersion(rsmd->GetConciseType(oneBasedIndex), m_is2xConnection);
      |                                        ~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:495:61: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  495 |     m_records[i].m_displaySize = rsmd->GetColumnDisplaySize(oneBasedIndex);
      |                                        ~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:496:55: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  496 |     m_records[i].m_octetLength = rsmd->GetOctetLength(oneBasedIndex);
      |                                        ~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:497:45: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  497 |     m_records[i].m_length = rsmd->GetLength(oneBasedIndex);
      |                                   ~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:499:28: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  499 |         rsmd->IsAutoUnique(oneBasedIndex) ? SQL_TRUE : SQL_FALSE;
      |               ~~~~~~~~~~~~ ^~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc:501:31: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  501 |         rsmd->IsCaseSensitive(oneBasedIndex) ? SQL_TRUE : SQL_FALSE;
      |               ~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
[5/619] Building CXX object src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_statement.cc.o
FAILED: src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_statement.cc.o
/opt/homebrew/bin/ccache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DARROW_HAVE_NEON -DARROW_WITH_TIMING_TESTS -DFMT_HEADER_ONLY -DGRPC_ENABLE_ASYNC -DGRPC_NAMESPACE_FOR_TLS_CREDENTIALS_OPTIONS=grpc::experimental -DGRPC_USE_CERTIFICATE_VERIFIER -DGRPC_USE_TLS_CHANNEL_CREDENTIALS_OPTIONS -I/path/to/arrow/cpp/build/src -I/path/to/arrow/cpp/src -I/path/to/arrow/cpp/src/generated -I/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include -I/path/to/arrow/cpp/build/_deps/spdlog-src/include -isystem /opt/homebrew/include -fno-aligned-new  -Qunused-arguments -fcolor-diagnostics  -Wall -Wextra -Wdocumentation -DARROW_WARN_DOCUMENTATION -Wshorten-64-to-32 -Wno-missing-braces -Wno-unused-parameter -Wno-constant-logical-operand -Wno-return-stack-address -Wdate-time -Wno-unknown-warning-option -Wno-pass-failed -march=armv8-a  -g -Werror -O0 -ggdb  -std=c++17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -fPIC -MD -MT src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_statement.cc.o -MF src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_statement.cc.o.d -o src/arrow/flight/sql/odbc/odbcabstraction/CMakeFiles/odbcabstraction.dir/odbc_impl/odbc_statement.cc.o -c /path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc:329:38: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  329 |         m_currenResult->BindColumn(i + 1, ardRecord.m_type, ardRecord.m_precision,
      |                         ~~~~~~~~~~ ~~^~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc:333:38: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  333 |         m_currenResult->BindColumn(i + 1,
      |                         ~~~~~~~~~~ ~~^~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc:699:27: error: comparison of integers of different signs: 'SQLSMALLINT' (aka 'short') and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
  699 |   } else if (recordNumber > m_ird->GetRecords().size()) {
      |              ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc:711:22: error: comparison of integers of different signs: 'SQLSMALLINT' (aka 'short') and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
  711 |     if (recordNumber > m_currentArd->GetRecords().size()) {
      |         ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/path/to/arrow/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc:724:22: error: comparison of integers of different signs: 'SQLSMALLINT' (aka 'short') and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
  724 |     if (recordNumber <= m_currentArd->GetRecords().size()) {
      |         ~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 errors generated.
[10/619] Building CXX object src/arrow/engine/CMakeFiles/arrow_substrait_objlib.dir/substrait/relation_internal.cc.o
ninja: build stopped: subcommand failed.

@hiroyuki-sato
Copy link
Collaborator

Simplified. (or just #if defined(__GNUC__))

diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h
index bd7ead678a..bec75d504f 100644
--- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h
+++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/encoding.h
@@ -115,7 +115,7 @@ inline void Utf8ToWcs(const char* utf8_string, std::vector<uint8_t>* result) {
   return Utf8ToWcs(utf8_string, strlen(utf8_string), result);
 }

-#if defined(__GNUC__) && __GNUC__ >= 11
+#if (defined(__GNUC__) && __GNUC__ >= 11) || defined(__clang__)
 #  pragma GCC diagnostic push
 #  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #endif
@@ -132,7 +132,7 @@ inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units,
   result->reserve(length_in_bytes);
   result->assign(data, data + length_in_bytes);
 }
-#if defined(__GNUC__) && __GNUC__ >= 11
+#if (defined(__GNUC__) && __GNUC__ >= 11) || defined(__clang__)
 #  pragma GCC diagnostic pop
 #endif

Using ARROW_SUPPRESS_DEPRECATION_WARNING
@alinaliBQ
Copy link
Collaborator Author

Hi @hiroyuki-sato , thanks for letting me know about clang. I have switched the code to use
ARROW_SUPPRESS_DEPRECATION_WARNING (defined in macros.h) which handles both GNUC and clang.

@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

@alinaliBQ alinaliBQ changed the title GH-46576: [C++] Resolve errors from Arrow Flight SQL ODBC build warnings GH-46576: [C++] Suppress codecvt_utf8 deprecation warning May 28, 2025
@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

@alinaliBQ
Copy link
Collaborator Author

This patch will fix encoding.h part, but It seems you need some additional works.

@hiroyuki-sato Thanks for raising this. The ODBC driver has only been tested in Windows environments and is not guaranteed to work on macOS/Linux. For now our team's only building the ODBC driver in Windows to start with (see #46099).

The goal of this PR is to suppress the deprecation warning for code that use codecvt_utf8. I have reworded the PR title as the old title wasn't clear on my part.

@alinaliBQ alinaliBQ marked this pull request as ready for review May 28, 2025 20:28
@alinaliBQ alinaliBQ requested a review from lidavidm as a code owner May 28, 2025 20:28
@alinaliBQ
Copy link
Collaborator Author

@lidavidm @kou The PR is ready for review

@github-actions
Copy link

⚠️ GitHub issue #46576 has been automatically assigned in GitHub to PR creator.

Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. CI failures look unrelated

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels May 28, 2025
@kou
Copy link
Member

kou commented May 29, 2025

Could you add this to prevent build error on macOS?

diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml
index 4bf162d7b1..5b3bbcb6bc 100644
--- a/.github/workflows/cpp.yml
+++ b/.github/workflows/cpp.yml
@@ -192,6 +192,8 @@ jobs:
       ARROW_BUILD_TESTS: ON
       ARROW_DATASET: ON
       ARROW_FLIGHT: ON
+      ARROW_FLIGHT_SQL: ON
+      ARROW_FLIGHT_SQL_ODBC: ON
       ARROW_GANDIVA: ON
       ARROW_GCS: ON
       ARROW_HDFS: ON

Or should we disable the ODBC driver on non Windows?

diff --git a/cpp/cmake_modules/DefineOptions.cmake b/cpp/cmake_modules/DefineOptions.cmake
index bf3e5e7c27..18e40649f7 100644
--- a/cpp/cmake_modules/DefineOptions.cmake
+++ b/cpp/cmake_modules/DefineOptions.cmake
@@ -107,6 +107,10 @@ macro(tsort_bool_option_dependencies)
 endmacro()
 
 macro(resolve_option_dependencies)
+  # Arrow Flight SQL ODBC is available only for Windows for now.
+  if(NOT MSVC_TOOLCHAIN)
+    set(ARROW_FLIGHT_SQL_ODBC OFF)
+  endif()
   if(MSVC_TOOLCHAIN)
     set(ARROW_USE_GLOG OFF)
   endif()

@hiroyuki-sato
Copy link
Collaborator

hiroyuki-sato commented May 29, 2025

@alinaliBQ Thanks.

-DARROW_FLIGHT_SQL_ODBC=OFF, -DARROW_FLIGHT_SQL=ON: compile succeed on macOS.

cmake .. --preset ninja-debug-maximal \
  -DCMAKE_INSTALL_PREFIX=/tmp/local \
  -DARROW_CUDA=OFF \
  -DARROW_SKYHOOK=OFF \
  -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
  -DARROW_EXTRA_ERROR_CONTEXT=OFF \
  -DARROW_FLIGHT_SQL_ODBC=OFF \
  -DARROW_FLIGHT_SQL=ON

@kou recommendation looks good to me. (for macOS environment.)

Co-Authored-By: Sutou Kouhei <kou@clear-code.com>
@alinaliBQ
Copy link
Collaborator Author

@kou Thanks, I have added the change in resolve_option_dependencies to disable ODBC build on non-windows platforms. I believe the workflows currently do not build the Flight SQL ODBC driver, and building it in Windows workflows would be part of #46099

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@kou kou merged commit 7f41ece into apache:main May 30, 2025
31 of 36 checks passed
@kou kou removed the awaiting merge Awaiting merge label May 30, 2025
@github-actions github-actions bot added the awaiting merge Awaiting merge label May 30, 2025
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 7f41ece.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

@alinaliBQ alinaliBQ deleted the GH-46576 branch June 17, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants