Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3576

Compiler warnings on mingw-w64

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.17.0-beta2, 1.17.0
    • Affects Version/s: 1.16.2
    • Component/s: mingw
    • Labels:
      None

      Hi! I maintain the R driver, which is based on mongo-c-driver.

      After upgrading to 1.16.2 we see the following compiler warnings when compiling with -pedantic. These need to be addressed to publish the R package.

      d:/Compiler/gcc-4.9.3/mingw_32/bin/gcc  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../windows/openssl-1.1.1/include -I. -Icommon -DBSON_COMPILATION -DMONGOC_COMPILATION -DMONGOC_HAVE_SASL_CLIENT_DONE -D__USE_MINGW_ANSI_STDIO    -I"d:/Compiler/gcc-4.9.3/local330/include"  -Wno-deprecated-declarations   -pedantic -O2 -Wall  -std=gnu99 -mtune=core2 -c mongoc/mongoc-util.c -o mongoc/mongoc-util.o
      mongoc/mongoc-util.c: In function '_mongoc_rand_simple':
      mongoc/mongoc-util.c:53:7: warning: spurious trailing '%' in format [-Wformat=]
             MONGOC_ERROR ("rand_s failed: %");
             ^ 

      And 

      d:/Compiler/gcc-4.9.3/mingw_32/bin/gcc  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../windows/openssl-1.1.1/include -I. -Icommon -DBSON_COMPILATION -DMONGOC_COMPILATION -DMONGOC_HAVE_SASL_CLIENT_DONE -D__USE_MINGW_ANSI_STDIO    -I"d:/Compiler/gcc-4.9.3/local330/include"  -Wno-deprecated-declarations   -pedantic -O2 -Wall  -std=gnu99 -mtune=core2 -c mongoc/mongoc-topology.c -o mongoc/mongoc-topology.o
      In file included from mongoc/mongoc-thread-private.h:24:0,
                       from mongoc/mongoc-topology-private.h:26,
                       from mongoc/mongoc-topology.c:25:
      mongoc/mongoc-topology.c: In function '_mongoc_topology_start_background_scanner':
      common/common-thread-private.h:58:38: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
          (!(*(_t) = CreateThread (NULL, 0, (void *) _f, _d, 0, NULL)))
                                            ^
      mongoc/mongoc-topology.c:1352:8: note: in expansion of macro 'bson_thread_create'
          r = bson_thread_create (
              ^
      common/common-thread-private.h:58:38: warning: ISO C forbids passing argument 3 of 'CreateThread' between function pointer and 'void *' [-Wpedantic]
          (!(*(_t) = CreateThread (NULL, 0, (void *) _f, _d, 0, NULL)))
                                            ^
      mongoc/mongoc-topology.c:1352:8: note: in expansion of macro 'bson_thread_create'
          r = bson_thread_create (
              ^
      In file included from D:/Compiler/gcc-4.9.3/mingw_32/i686-w64-mingw32/include/winbase.h:29:0,
                       from D:/Compiler/gcc-4.9.3/mingw_32/i686-w64-mingw32/include/windows.h:70,
                       from D:/Compiler/gcc-4.9.3/mingw_32/i686-w64-mingw32/include/winsock2.h:23,
                       from ./bson/bson-compat.h:48,
                       from ./bson/bson.h:23,
                       from mongoc/mongoc-handshake.h:23,
                       from mongoc/mongoc-topology.c:19:
      D:/Compiler/gcc-4.9.3/mingw_32/i686-w64-mingw32/include/processthreadsapi.h:84:28: note: expected 'LPTHREAD_START_ROUTINE' but argument is of type 'void *'
         WINBASEAPI HANDLE WINAPI CreateThread (LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
                                  ^
       

      and

      d:/Compiler/gcc-4.9.3/mingw_32/bin/gcc  -I"D:/RCompile/recent/R/include" -DNDEBUG -I../windows/openssl-1.1.1/include -I. -Icommon -DBSON_COMPILATION -DMONGOC_COMPILATION -DMONGOC_HAVE_SASL_CLIENT_DONE -D__USE_MINGW_ANSI_STDIO    -I"d:/Compiler/gcc-4.9.3/local330/include"  -Wno-deprecated-declarations   -pedantic -O2 -Wall  -std=gnu99 -mtune=core2 -c mongoc/mongoc-openssl.c -o mongoc/mongoc-openssl.o
      mongoc/mongoc-openssl.c: In function '_mongoc_openssl_import_cert_store':
      mongoc/mongoc-openssl.c:133:7: warning: format '%X' expects argument of type 'unsigned int', but argument 4 has type 'DWORD' [-Wformat=]
             MONGOC_ERROR ("Can't open CA store: 0x%.8X: '%s'", GetLastError (), msg);
             ^ 

       

      A full build log is available here: https://win-builder.r-project.org/incoming_pretest/mongolite_2.2.0_20200317_230736/Windows/00install.out

            Assignee:
            roberto.sanchez@mongodb.com Roberto Sanchez
            Reporter:
            jeroen@berkeley.edu Jeroen Ooms
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: