This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 4cecdc2d fix(r): Build with __USE_MINGW_ANSI_STDIO to enable use of 
lld in format strings (#1180)
4cecdc2d is described below

commit 4cecdc2dbe24a209ce2b77b4b7e005260a0fcca5
Author: Dewey Dunnington <[email protected]>
AuthorDate: Wed Oct 11 09:10:25 2023 -0300

    fix(r): Build with __USE_MINGW_ANSI_STDIO to enable use of lld in format 
strings (#1180)
    
    Closes #1113.
    
    The mingw headers appear to be a little inconsistent with respect to the
    definitions of `PRId64` and the format check attribute. I think this fix
    it the least intrusive way to deal with that but I'm open to thoughts!
---
 c/driver/common/utils.h           | 7 ++++---
 r/adbcpostgresql/src/Makevars.win | 2 +-
 r/adbcsqlite/configure            | 7 ++++++-
 r/adbcsqlite/configure.win        | 2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/c/driver/common/utils.h b/c/driver/common/utils.h
index e3d81cb0..1ac6a42a 100644
--- a/c/driver/common/utils.h
+++ b/c/driver/common/utils.h
@@ -30,9 +30,10 @@ extern "C" {
 
 int AdbcStatusCodeToErrno(AdbcStatusCode code);
 
-// The printf checking attribute doesn't work properly on gcc 4.8
-// and results in spurious compiler warnings
-#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 5)
+// If using mingw's c99-compliant printf, we need a different format-checking 
attribute
+#if defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW_PRINTF_FORMAT)
+#define ADBC_CHECK_PRINTF_ATTRIBUTE 
__attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)))
+#elif defined(__GNUC__)
 #define ADBC_CHECK_PRINTF_ATTRIBUTE __attribute__((format(printf, 2, 3)))
 #else
 #define ADBC_CHECK_PRINTF_ATTRIBUTE
diff --git a/r/adbcpostgresql/src/Makevars.win 
b/r/adbcpostgresql/src/Makevars.win
index 0b4ab3c5..e98dc091 100644
--- a/r/adbcpostgresql/src/Makevars.win
+++ b/r/adbcpostgresql/src/Makevars.win
@@ -17,7 +17,7 @@
 
 VERSION = 13.2.0
 RWINLIB = ../windows/libpq-$(VERSION)
-PKG_CPPFLAGS = -I$(RWINLIB)/include -I../src -DADBC_EXPORT=""
+PKG_CPPFLAGS = -I$(RWINLIB)/include -I../src -DADBC_EXPORT="" 
-D__USE_MINGW_ANSI_STDIO
 PKG_LIBS = -L$(RWINLIB)/lib${R_ARCH}${CRT} \
        -lpq -lpgport -lpgcommon -lssl -lcrypto -lwsock32 -lsecur32 -lws2_32 
-lgdi32 -lcrypt32 -lwldap32
 
diff --git a/r/adbcsqlite/configure b/r/adbcsqlite/configure
index 084aa224..95f48e83 100755
--- a/r/adbcsqlite/configure
+++ b/r/adbcsqlite/configure
@@ -40,7 +40,7 @@ echo "Testing R CMD SHLIB with $PKG_CPPFLAGS $PKG_LIBS 
-lsqlite3"
 PKG_CPPFLAGS="$PKG_CPPFLAGS" PKG_LIBS="$PKG_LIBS -lsqlite3" \
   $R_HOME/bin/R CMD SHLIB tools/test.c -o sqlite_test >sqlite_test.log 2>&1
 
-if [ $? -ne 0 ] || [ ! -z "$FORCE_VENDORED_SQLITE3"]; then
+if [ $? -ne 0 ] || [ ! -z "$FORCE_VENDORED_SQLITE3" ]; then
   echo "Forcing vendored sqlite3 or #include <sqlite3.h>/-lsqlite3 failed:"
   cat sqlite_test.log
 
@@ -52,6 +52,11 @@ else
   PKG_LIBS="$PKG_LIBS -lsqlite3"
 fi
 
+# Add mingw printf flag if on Windows
+if [ ! -z "$R_ADBC_SQLITE_ON_WINDOWS" ]; then
+  PKG_CPPFLAGS="$PKG_CPPFLAGS -D__USE_MINGW_ANSI_STDIO"
+fi
+
 rm -f tools/test.o sqlite_test sqlite_test.log || true
 
 sed \
diff --git a/r/adbcsqlite/configure.win b/r/adbcsqlite/configure.win
index 105bb7f4..336156db 100755
--- a/r/adbcsqlite/configure.win
+++ b/r/adbcsqlite/configure.win
@@ -16,4 +16,4 @@
 # under the License.
 
 # Just call the original configure script
-./configure
+R_ADBC_SQLITE_ON_WINDOWS=1 ./configure

Reply via email to