omegahat / RDCOMClient

GNU General Public License v2.0
77 stars 34 forks source link

RDCOMClient for R 4.1.0? #32

Open yb2125 opened 2 years ago

yb2125 commented 2 years ago

I am deciding whether to install the newest version of R on a new computer. Will RDCOMClient support R 4.1.0? Thanks!

daauerbach commented 2 years ago

I was able to get the package installed, and the library() and COMCreate calls without issue, but I'm getting fatal errors (session abort, RStudio bomb) whenever I try anything beyond that. [Edit: that last line in the screenshot produces the abort as do other similar] Same thing when running from command line outside RStudio.

When I revert to 4.0.5, then things run ok. Fingers crossed for a fix/update, as I have code using the 4.1.0 native pipe but would like to still use the package...

devtools::install_github("omegahat/RDCOMClient") #worked with 4.1.0

##no longer working?
#install.packages("RDCOMClient", repos = "http://www.omegahat.net/R")

image

daauerbach commented 2 years ago

Sorry I didn't see this earlier, but the fork from @BSchamberger described in #24 has resolved this for me.

So, that version 0.95-0 does work with 4.1.0

Perhaps @duncantl can review and merge here at some point...

devtools::install_github("BSchamberger/RDCOMClient")
library(RDCOMClient)
xlApp <- COMCreate("Excel.Application")
wb <- xlApp$Workbooks()$Open("path/to/your/.xlsx")
...other stuff

image

duncantl commented 2 years ago

Hi For the version that crashed - was that installing from source or from a previous binary?

daauerbach commented 2 years ago

Source. The version that worked with 4.0.5, and installed without error but crashed 4.1.0 was the default args in devtools::install_github("omegahat/RDCOMClient") (which is basically same as the remotes and build = TRUE).

datafj commented 2 years ago

Not sure is this just me, but devtools::install_github("omegahat/RDCOMClient") no longer works in R 4.2.0:

* installing *source* package 'RDCOMClient' ...
** using staged installation
** libs
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c COMError.cpp -o COMError.o
COMError.cpp:364: warning: "_countof" redefined
  364 | #define _countof(array) (sizeof(array)/sizeof(array[0]))
      | 
In file included from C:/rtools40/ucrt64/include/c++/10.3.0/cstdlib:75,
                 from C:/rtools40/ucrt64/include/c++/10.3.0/stdlib.h:36,
                 from C:/rtools40/ucrt64/lib/gcc/x86_64-w64-mingw32/10.3.0/include/mm_malloc.h:27,
                 from C:/rtools40/ucrt64/lib/gcc/x86_64-w64-mingw32/10.3.0/include/xmmintrin.h:34,
                 from C:/rtools40/ucrt64/lib/gcc/x86_64-w64-mingw32/10.3.0/include/immintrin.h:29,
                 from C:/rtools40/ucrt64/lib/gcc/x86_64-w64-mingw32/10.3.0/include/x86intrin.h:32,
                 from C:/rtools40/ucrt64/x86_64-w64-mingw32/include/winnt.h:1555,
                 from C:/rtools40/ucrt64/x86_64-w64-mingw32/include/minwindef.h:163,
                 from C:/rtools40/ucrt64/x86_64-w64-mingw32/include/windef.h:9,
                 from C:/rtools40/ucrt64/x86_64-w64-mingw32/include/windows.h:69,
                 from RCOMObject.h:23,
                 from COMError.cpp:1:
C:/rtools40/ucrt64/x86_64-w64-mingw32/include/stdlib.h:381: note: this is the location of the previous definition
  381 | #define _countof(_Array) sizeof(*__countof_helper(_Array))
      | 
In file included from COMError.cpp:1:
RCOMObject.h: In member function 'virtual ULONG RCOMObject::Release()':
RCOMObject.h:61:43: warning: deleting object of abstract class type 'RCOMObject' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
   61 |                                           delete this;
      |                                           ^~~~~~~~~~~
COMError.cpp: At global scope:
COMError.cpp:8:16: warning: 'RDCOM_WriteErrors' initialized and declared 'extern'
    8 | extern "C" int RDCOM_WriteErrors = 1;
      |                ^~~~~~~~~~~~~~~~~
COMError.cpp: In function 'void GetScodeString(HRESULT, LPTSTR, int)':
COMError.cpp:388:16: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Wformat=]
  388 |  sprintf(buf, ("OLE error 0x%08x"), hr);
      |               ~^~~~~~~~~~~~~~~~~~~  ~~
      |                                     |
      |                                     HRESULT {aka long int}
COMError.cpp: In function 'HRESULT checkErrorInfo(IUnknown*, HRESULT, SEXPREC**)':
COMError.cpp:426:38: warning: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Wformat=]
  426 |   fprintf(stderr, "<checkErrorInfo> %X \n", status);
      |                                     ~^      ~~~~~~
      |                                      |      |
      |                                      |      HRESULT {aka long int}
      |                                      unsigned int
      |                                     %lX
COMError.cpp:487:4: error: 'PROBLEM' was not declared in this scope
  487 |    PROBLEM "%s", str
      |    ^~~~~~~
COMError.cpp:494:4: error: 'PROBLEM' was not declared in this scope
  494 |    PROBLEM "%s (%s)", str, FromBstr(ostr)
      |    ^~~~~~~
make: *** [C:/PROGRA~1/R/R-42~1.0/etc/x64/Makeconf:259: COMError.o] Error 1
ERROR: compilation failed for package 'RDCOMClient'
duncantl commented 2 years ago

Thanks @datafj. Not you. There were changes to the R header files so that the PROBLEM, ERROR, ... macros are no longer defined by default. I'll update on github and hopefully you can test. I don't have a Windows (virtual) machine setup to test.

duncantl commented 2 years ago

It would be great if you check again now. Thanks.

datafj commented 2 years ago

The error messages are different now:

fied)
* installing *source* package 'RDCOMClient' ...
** using staged installation
** libs
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c COMError.cpp -o COMError.o
COMError.cpp:364: warning: "_countof" redefined
  364 | #define _countof(array) (sizeof(array)/sizeof(array[0]))
      | 
In file included from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\c++\cstdlib:75,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\c++\stdlib.h:36,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\mm_malloc.h:27,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\xmmintrin.h:34,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\immintrin.h:29,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\x86intrin.h:32,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\winnt.h:1555,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\minwindef.h:163,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\windef.h:9,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\windows.h:69,
                 from RCOMObject.h:23,
                 from COMError.cpp:1:
c:\rtools42\x86_64-w64-mingw32.static.posix\include\stdlib.h:381: note: this is the location of the previous definition
  381 | #define _countof(_Array) sizeof(*__countof_helper(_Array))
      | 
In file included from COMError.cpp:1:
RCOMObject.h: In member function 'virtual ULONG RCOMObject::Release()':
RCOMObject.h:61:43: warning: deleting object of abstract class type 'RCOMObject' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
   61 |                                           delete this;
      |                                           ^~~~~~~~~~~
COMError.cpp: At global scope:
COMError.cpp:8:16: warning: 'RDCOM_WriteErrors' initialized and declared 'extern'
    8 | extern "C" int RDCOM_WriteErrors = 1;
      |                ^~~~~~~~~~~~~~~~~
COMError.cpp: In function 'void GetScodeString(HRESULT, LPTSTR, int)':
COMError.cpp:388:16: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Wformat=]
  388 |  sprintf(buf, ("OLE error 0x%08x"), hr);
      |               ~^~~~~~~~~~~~~~~~~~~  ~~
      |                                     |
      |                                     HRESULT {aka long int}
COMError.cpp: In function 'HRESULT checkErrorInfo(IUnknown*, HRESULT, SEXPREC**)':
COMError.cpp:426:38: warning: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Wformat=]
  426 |   fprintf(stderr, "<checkErrorInfo> %X \n", status);
      |                                     ~^      ~~~~~~
      |                                      |      |
      |                                      |      HRESULT {aka long int}
      |                                      unsigned int
      |                                     %lX
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c RCOMObject.cpp -o RCOMObject.o
In file included from RCOMObject.cpp:1:
RCOMObject.h: In member function 'virtual ULONG RCOMObject::Release()':
RCOMObject.h:61:43: warning: deleting object of abstract class type 'RCOMObject' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
   61 |                                           delete this;
      |                                           ^~~~~~~~~~~
RCOMObject.cpp: In member function 'virtual HRESULT RCOMEnvironmentObject::GetIDsOfNames(const IID&, OLECHAR**, UINT, LCID, DISPID*)':
RCOMObject.cpp:121:8: warning: unused variable 'sid' [-Wunused-variable]
  121 |   SEXP sid;
      |        ^~~
RCOMObject.cpp:122:7: warning: unused variable 'i' [-Wunused-variable]
  122 |   int i, n;
      |       ^
RCOMObject.cpp:122:10: warning: unused variable 'n' [-Wunused-variable]
  122 |   int i, n;
      |          ^
RCOMObject.cpp:124:8: warning: unused variable 'str' [-Wunused-variable]
  124 |   char str[90];
      |        ^~~
In file included from RCOMObject.h:51,
                 from RCOMObject.cpp:1:
RCOMObject.cpp: In member function 'HRESULT RCOMObject::lookupRName(SEXP, const char*, DISPID*)':
RCOMObject.cpp:172:14: warning: format '%d' expects argument of type 'int', but argument 4 has type 'DISPID' {aka 'long int'} [-Wformat=]
  172 |     errorLog("Method id for %s = %d\n", str,  *id);
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~        ~~~
      |                                               |
      |                                               DISPID {aka long int}
RUtils.h:65:73: note: in definition of macro 'errorLog'
   65 | #define errorLog(a,...) if(RDCOM_WriteErrors) { fprintf(getErrorFILE(), a, ##__VA_ARGS__); fflush(getErrorFILE()); }
      |                                                                         ^
RCOMObject.cpp:172:35: note: format string is defined here
  172 |     errorLog("Method id for %s = %d\n", str,  *id);
      |                                  ~^
      |                                   |
      |                                   int
      |                                  %ld
In file included from RCOMObject.h:51,
                 from RCOMObject.cpp:1:
RCOMObject.cpp: In member function 'virtual HRESULT RCOMEnvironmentObject::Invoke(DISPID, const IID&, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*)':
RCOMObject.cpp:186:11: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DISPID' {aka 'long int'} [-Wformat=]
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~
      |                                         |
      |                                         DISPID {aka long int}
RUtils.h:65:73: note: in definition of macro 'errorLog'
   65 | #define errorLog(a,...) if(RDCOM_WriteErrors) { fprintf(getErrorFILE(), a, ##__VA_ARGS__); fflush(getErrorFILE()); }
      |                                                                         ^
RCOMObject.cpp:186:23: note: format string is defined here
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |                      ~^
      |                       |
      |                       int
      |                      %ld
In file included from RCOMObject.h:51,
                 from RCOMObject.cpp:1:
RCOMObject.cpp:186:11: warning: format '%s' expects argument of type 'char*', but argument 4 has type 'int' [-Wformat=]
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~       ~~~~~~
      |                                             |
      |                                             int
RUtils.h:65:73: note: in definition of macro 'errorLog'
   65 | #define errorLog(a,...) if(RDCOM_WriteErrors) { fprintf(getErrorFILE(), a, ##__VA_ARGS__); fflush(getErrorFILE()); }
      |                                                                         ^
RCOMObject.cpp:186:36: note: format string is defined here
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |                                   ~^
      |                                    |
      |                                    char*
      |                                   %d
RCOMObject.cpp: In function 'SEXPREC* asRStringVector(OLECHAR**, UINT)':
RCOMObject.cpp:300:16: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  300 |   for(i = 0; i < cNames; i++) {
      |              ~~^~~~~~~~
RCOMObject.cpp: In member function 'virtual HRESULT RCOMSObject::GetIDsOfNames(const IID&, OLECHAR**, UINT, LCID, DISPID*)':
RCOMObject.cpp:322:18: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  322 |     for(i = 0; i < cNames; i++) {
      |                ~~^~~~~~~~
RCOMObject.cpp:312:16: warning: unused variable 'tmp' [-Wunused-variable]
  312 |   SEXP e, val, tmp;
      |                ^~~
RCOMObject.cpp: In member function 'virtual HRESULT RCOMSObject::Invoke(DISPID, const IID&, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*)':
RCOMObject.cpp:381:19: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  381 |     for(i = 0 ; i < parms->cArgs; i++) {
      |                 ~~^~~~~~~~~~~~~~
RCOMObject.cpp:393:18: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  393 |     for(i = 0; i < parms->cNamedArgs   ; i++) {
      |                ~~^~~~~~~~~~~~~~~~~~~
RCOMObject.cpp:358:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  358 |   HRESULT hr;
      |           ^~
RCOMObject.cpp: In function 'HRESULT processCOMError(SEXP, EXCEPINFO*, UINT*)':
RCOMObject.cpp:430:19: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  430 |   if(isClass(obj, "COMReturnValue")) {
      |                   ^~~~~~~~~~~~~~~~
RCOMObject.cpp: In function 'bool isCOMError(SEXP)':
RCOMObject.cpp:441:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  441 |   return(isClass(obj, "COMError"));
      |                       ^~~~~~~~~~
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c RUtils.c -o RUtils.o
RUtils.c: In function 'derefRDCOMPointer':
RUtils.c:20:4: error: 'PROBLEM' undeclared (first use in this function)
   20 |    PROBLEM "Looking at a COM object that does not have an external pointer in the ref slot"
      |    ^~~~~~~
RUtils.c:20:4: note: each undeclared identifier is reported only once for each function it appears in
RUtils.c:20:11: error: expected ';' before string constant
   20 |    PROBLEM "Looking at a COM object that does not have an external pointer in the ref slot"
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           ;
RUtils.c:34:11: error: expected ';' before string constant
   34 |    PROBLEM "RDCOM Reference object is not valid (NULL). This may be due to restoring it from a previous session."
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           ;
make: *** [C:/PROGRA~1/R/R-42~1.0/etc/x64/Makeconf:252: RUtils.o] Error 1
ERROR: compilation failed for package 'RDCOMClient'
duncantl commented 2 years ago

Thank you. I'll take a look. Sorry I cannot readily compile this on one of my own machines.

duncantl commented 2 years ago

A simple issue apparently that not all C++ files were including that single header. Hopefully fixed now on the the updated repository. Thanks again.

datafj commented 2 years ago

This seems compiled through, and the library was installed and can be loaded.

There are still some messages.

* installing *source* package 'RDCOMClient' ...
** using staged installation
** libs
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c COMError.cpp -o COMError.o
COMError.cpp:364: warning: "_countof" redefined
  364 | #define _countof(array) (sizeof(array)/sizeof(array[0]))
      | 
In file included from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\c++\cstdlib:75,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\c++\stdlib.h:36,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\mm_malloc.h:27,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\xmmintrin.h:34,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\immintrin.h:29,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\lib\gcc\x86_64-w64-mingw32.static.posix\10.3.0\include\x86intrin.h:32,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\winnt.h:1555,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\minwindef.h:163,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\windef.h:9,
                 from c:\rtools42\x86_64-w64-mingw32.static.posix\include\windows.h:69,
                 from RCOMObject.h:23,
                 from COMError.cpp:1:
c:\rtools42\x86_64-w64-mingw32.static.posix\include\stdlib.h:381: note: this is the location of the previous definition
  381 | #define _countof(_Array) sizeof(*__countof_helper(_Array))
      | 
In file included from COMError.cpp:1:
RCOMObject.h: In member function 'virtual ULONG RCOMObject::Release()':
RCOMObject.h:61:43: warning: deleting object of abstract class type 'RCOMObject' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
   61 |                                           delete this;
      |                                           ^~~~~~~~~~~
COMError.cpp: At global scope:
COMError.cpp:8:16: warning: 'RDCOM_WriteErrors' initialized and declared 'extern'
    8 | extern "C" int RDCOM_WriteErrors = 1;
      |                ^~~~~~~~~~~~~~~~~
COMError.cpp: In function 'void GetScodeString(HRESULT, LPTSTR, int)':
COMError.cpp:388:16: warning: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Wformat=]
  388 |  sprintf(buf, ("OLE error 0x%08x"), hr);
      |               ~^~~~~~~~~~~~~~~~~~~  ~~
      |                                     |
      |                                     HRESULT {aka long int}
COMError.cpp: In function 'HRESULT checkErrorInfo(IUnknown*, HRESULT, SEXPREC**)':
COMError.cpp:426:38: warning: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Wformat=]
  426 |   fprintf(stderr, "<checkErrorInfo> %X \n", status);
      |                                     ~^      ~~~~~~
      |                                      |      |
      |                                      |      HRESULT {aka long int}
      |                                      unsigned int
      |                                     %lX
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c RCOMObject.cpp -o RCOMObject.o
In file included from RCOMObject.cpp:1:
RCOMObject.h: In member function 'virtual ULONG RCOMObject::Release()':
RCOMObject.h:61:43: warning: deleting object of abstract class type 'RCOMObject' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
   61 |                                           delete this;
      |                                           ^~~~~~~~~~~
RCOMObject.cpp: In member function 'virtual HRESULT RCOMEnvironmentObject::GetIDsOfNames(const IID&, OLECHAR**, UINT, LCID, DISPID*)':
RCOMObject.cpp:121:8: warning: unused variable 'sid' [-Wunused-variable]
  121 |   SEXP sid;
      |        ^~~
RCOMObject.cpp:122:7: warning: unused variable 'i' [-Wunused-variable]
  122 |   int i, n;
      |       ^
RCOMObject.cpp:122:10: warning: unused variable 'n' [-Wunused-variable]
  122 |   int i, n;
      |          ^
RCOMObject.cpp:124:8: warning: unused variable 'str' [-Wunused-variable]
  124 |   char str[90];
      |        ^~~
In file included from RCOMObject.h:51,
                 from RCOMObject.cpp:1:
RCOMObject.cpp: In member function 'HRESULT RCOMObject::lookupRName(SEXP, const char*, DISPID*)':
RCOMObject.cpp:172:14: warning: format '%d' expects argument of type 'int', but argument 4 has type 'DISPID' {aka 'long int'} [-Wformat=]
  172 |     errorLog("Method id for %s = %d\n", str,  *id);
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~        ~~~
      |                                               |
      |                                               DISPID {aka long int}
RUtils.h:65:73: note: in definition of macro 'errorLog'
   65 | #define errorLog(a,...) if(RDCOM_WriteErrors) { fprintf(getErrorFILE(), a, ##__VA_ARGS__); fflush(getErrorFILE()); }
      |                                                                         ^
RCOMObject.cpp:172:35: note: format string is defined here
  172 |     errorLog("Method id for %s = %d\n", str,  *id);
      |                                  ~^
      |                                   |
      |                                   int
      |                                  %ld
In file included from RCOMObject.h:51,
                 from RCOMObject.cpp:1:
RCOMObject.cpp: In member function 'virtual HRESULT RCOMEnvironmentObject::Invoke(DISPID, const IID&, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*)':
RCOMObject.cpp:186:11: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DISPID' {aka 'long int'} [-Wformat=]
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~
      |                                         |
      |                                         DISPID {aka long int}
RUtils.h:65:73: note: in definition of macro 'errorLog'
   65 | #define errorLog(a,...) if(RDCOM_WriteErrors) { fprintf(getErrorFILE(), a, ##__VA_ARGS__); fflush(getErrorFILE()); }
      |                                                                         ^
RCOMObject.cpp:186:23: note: format string is defined here
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |                      ~^
      |                       |
      |                       int
      |                      %ld
In file included from RCOMObject.h:51,
                 from RCOMObject.cpp:1:
RCOMObject.cpp:186:11: warning: format '%s' expects argument of type 'char*', but argument 4 has type 'int' [-Wformat=]
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~       ~~~~~~
      |                                             |
      |                                             int
RUtils.h:65:73: note: in definition of macro 'errorLog'
   65 | #define errorLog(a,...) if(RDCOM_WriteErrors) { fprintf(getErrorFILE(), a, ##__VA_ARGS__); fflush(getErrorFILE()); }
      |                                                                         ^
RCOMObject.cpp:186:36: note: format string is defined here
  186 |  errorLog("Method id %d, method = %s",  id, method);
      |                                   ~^
      |                                    |
      |                                    char*
      |                                   %d
RCOMObject.cpp: In function 'SEXPREC* asRStringVector(OLECHAR**, UINT)':
RCOMObject.cpp:300:16: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  300 |   for(i = 0; i < cNames; i++) {
      |              ~~^~~~~~~~
RCOMObject.cpp: In member function 'virtual HRESULT RCOMSObject::GetIDsOfNames(const IID&, OLECHAR**, UINT, LCID, DISPID*)':
RCOMObject.cpp:322:18: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  322 |     for(i = 0; i < cNames; i++) {
      |                ~~^~~~~~~~
RCOMObject.cpp:312:16: warning: unused variable 'tmp' [-Wunused-variable]
  312 |   SEXP e, val, tmp;
      |                ^~~
RCOMObject.cpp: In member function 'virtual HRESULT RCOMSObject::Invoke(DISPID, const IID&, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*)':
RCOMObject.cpp:381:19: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  381 |     for(i = 0 ; i < parms->cArgs; i++) {
      |                 ~~^~~~~~~~~~~~~~
RCOMObject.cpp:393:18: warning: comparison of integer expressions of different signedness: 'int' and 'UINT' {aka 'unsigned int'} [-Wsign-compare]
  393 |     for(i = 0; i < parms->cNamedArgs   ; i++) {
      |                ~~^~~~~~~~~~~~~~~~~~~
RCOMObject.cpp:358:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  358 |   HRESULT hr;
      |           ^~
RCOMObject.cpp: In function 'HRESULT processCOMError(SEXP, EXCEPINFO*, UINT*)':
RCOMObject.cpp:430:19: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  430 |   if(isClass(obj, "COMReturnValue")) {
      |                   ^~~~~~~~~~~~~~~~
RCOMObject.cpp: In function 'bool isCOMError(SEXP)':
RCOMObject.cpp:441:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  441 |   return(isClass(obj, "COMError"));
      |                       ^~~~~~~~~~
gcc  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c RUtils.c -o RUtils.o
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c connect.cpp -o connect.o
connect.cpp: In function 'HRESULT R_getCOMArgs(SEXP, DISPPARAMS*, DISPID*, int, int*)':
connect.cpp:407:10: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  407 |  HRESULT hr;
      |          ^~
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.0/include" -DNDEBUG -D_GNU_ -DNO_PYCOM_IPROVIDECLASSINFO -I.    -I"C:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Wno-deprecated    -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c converters.cpp -o converters.o
In file included from converters.cpp:1:
RCOMObject.h: In member function 'virtual ULONG RCOMObject::Release()':
RCOMObject.h:61:43: warning: deleting object of abstract class type 'RCOMObject' which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
   61 |                                           delete this;
      |                                           ^~~~~~~~~~~
converters.cpp: In function 'SEXPREC* R_convertDCOMObjectToR(VARIANT*)':
converters.cpp:365:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  365 |   HRESULT hr;
      |           ^~
g++ -std=gnu++11 -shared -s -static-libgcc -o RDCOMClient.dll tmp.def COMError.o RCOMObject.o RUtils.o connect.o converters.o -lole32 -loleaut32 -luuid -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools42/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-42~1.0/bin/x64 -lR
installing to C:/Users/jflyc/AppData/Local/R/win-library/4.2/00LOCK-RDCOMClient/00new/RDCOMClient/libs/x64
** R
** inst
** byte-compile and prepare package for lazy loading
Creating a generic function for 'lapply' from package 'base' in package 'RDCOMClient'
Creating a generic function for 'sapply' from package 'base' in package 'RDCOMClient'
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (RDCOMClient)
duncantl commented 2 years ago

Thank you. I'll clean up these warnings but didn't want to confound things with fixing the show-stopping errors. Thanks again.

duncanaw commented 2 years ago

Love using this package, so many applications. Unfortunately living without admin privileges, and so are eagerly awaiting the next binary release!

gwd666 commented 2 years ago

A comment from the "side" - this package is the only "serious" tool to work with [Microsoft SSAS] OLAP (aka Cube) data in R via COMCreate("ADOMD.Catalog") functionality - just in case someone tries to do that! Except for a deadly

Error in createCOMReference(<pointer: 0x00000137dfcb6550>, "COMIDispatch") : 
  could not find function "createCOMReference"

error that keeps popping up lately in R-4, when trying to integrate RDCOMClient into my "RCube" package :-( Weirdly it will work with devtools::load_all() but something goes astray when depending on function (or NAMESPACE) exports? But the package is simply awesome - so I hope it will get the updates needed to work in R-4 (again) as well.

For now I seem to be able to solve the above topic via "the ugly" solution ("ugly' in the sense that it is regualarly discouraged) to put RDCOMClient in the Depends: (instead of the Imports:) section of my DESCRIPTION file.

BSchamberger commented 2 years ago

A comment from the "side" - this package is the only "serious" tool to work with [Microsoft SSAS] OLAP (aka Cube) data in R via COMCreate("ADOMD.Catalog") functionality - just in case someone tries to do that! Except for a deadly

Error in createCOMReference(<pointer: 0x00000137dfcb6550>, "COMIDispatch") : 
  could not find function "createCOMReference"

error that keeps popping up lately in R-4, when trying to integrate RDCOMClient into my "RCube" package :-( Weirdly it will work with devtools::load_all() but something goes astray when depending on function (or NAMESPACE) exports? But the package is simply awesome - so I hope it will get the updates needed to work in R-4 (again) as well.

For now I seem to be able to solve the above topic via "the ugly" solution ("ugly' in the sense that it is regualarly discouraged) to put RDCOMClient in the Depends: (instead of the Imports:) section of my DESCRIPTION file.

I have solved a similar issue in one of my packages by explicitly calling require(RDCOMClient) before the COMCreate call. This is also not ideal because it changes the search path. I believe that the underlying issue is createCOMReferenceObject in RUtils.c . I made a simple attempt of fixing it at this commit https://github.com/BSchamberger/RDCOMClient/commit/96be0dcd6168144bdba31e543afeb07fb4de63f4. However, this probably derails this discussion.

gwd666 commented 1 year ago

@BSchamberger

made a simple attempt of fixing it at this commit BSchamberger/RDCOMClient@96be0dc

I noticed that and already updated my RDCOMClient package fork with your adjustments! Works like a charm. Just hope that @duncantl will pick your PR on that one ... or incorporate something along those lines to address that.