sneumann / Rdisop

This is the git repository matching the Bioconductor package Rdisop: Decomposition of Isotopic Patterns
4 stars 7 forks source link

Installation on fedora-clang/macOS with clang 14 and C++17 #24

Closed sneumann closed 1 year ago

sneumann commented 1 year ago

Hi, as reported by Prof. Brian Ripley: These do not install on fedora-clang and macOS with Apple clang 14 (at least) with R's new default of C++17. Log extracts below. C++ has never supported 'register' (except in system headers), and all the removed functions were deprecated as long ago as C++11. You could declare a C++ standard (see 'Writing R Extensions') but it would be better to modernize your code.

In file included from disop.cpp:22:
./imslib/src/ims/composedelement.h:204:58: error: no template named 
'auto_ptr' in namespace 'std'
                 void initializeElements(const Alphabet& alphabet, 
std::auto_ptr<sequence_parser_type> parser)
                                                                   ~~~~~^
In file included from disop.cpp:26:
./imslib/src/ims/decomp/realmassdecomposer.h:103:8: error: no template 
named 'auto_ptr' in namespace 'std'
                 std::auto_ptr<integer_decomposer_type> decomposer;
                 ~~~~~^
In file included from disop.cpp:28:
./imslib/src/ims/decomp/decomputils.h:74:80: error: no member named 
'bind2nd' in namespace 'std'
         valuesRange.erase(std::remove_if(valuesRange.begin(), 
valuesRange.end(), std::bind2nd(std::less<T>(), 0)), valuesRange.end());

          ~~~~~^
./imslib/src/ims/decomp/decomputils.h:81:80: error: no member named 
'bind2nd' in namespace 'std'
         valuesRange.erase(std::remove_if(valuesRange.begin(), 
valuesRange.end(), std::bind2nd(std::less<T>(), 0)), valuesRange.end());

          ~~~~~^
disop.cpp:325:6: error: use of undeclared identifier 'bind2nd'

bind2nd(multiplies<abundance_type>(), scale));  // operation (*scale)

In e.g. https://github.com/sneumann/Rdisop/blob/855a7ac9dfd1d61109ce70397d6a1b4f08ed1a5a/src/imslib/src/ims/composedelement.h#L204 https://github.com/sneumann/Rdisop/blob/855a7ac9dfd1d61109ce70397d6a1b4f08ed1a5a/src/imslib/src/ims/decomp/realmassdecomposer.h#L103 and other places. Yours, Steffen

sneumann commented 1 year ago

Addendum:

For Rdisop, gcc 12 is warning on

imslib/src/ims/alphabet.cpp:74:57: warning: 
‘std::const_mem_fun_ref_t<_Ret, _Tp> std::mem_fun_ref(_Ret (_Tp::*)() 
const) [with _Ret = const __cxx11::basic_string<char>&; _Tp = 
ims::Element]’ is deprecated: use 'std::mem_fn' instead 
[-Wdeprecated-declarations]
    74 | 
std::mem_fun_ref(&element_type::getName),
       | 
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

and

./imslib/src/ims/utils/compose_f_gx_t.h:66:16: warning: ‘template<class 
_Arg, class _Result> struct std::unary_function’ is deprecated 
[-Wdeprecated-declarations]
    66 |  : public std::unary_function<typename OP2::argument_type,
       |                ^~~~~~~~~~~~~~

./imslib/src/ims/utils/compose_f_gx_hy_t.h:57:16: warning: 
‘template<class _Arg1, class _Arg2, class _Result> struct 
std::binary_function’ is deprecated [-Wdeprecated-declarations]
    57 |  : public std::binary_function<typename OP2::argument_type,
       |                ^~~~~~~~~~~~~~~

all of which are supposed to be removed in C++17.
sneumann commented 1 year ago

Hi, here is how to easily reproduce:

docker run --rm -it rhub/fedora-clang-devel:latest bash

export PATH=/tmp/R-devel/bin/:$PATH
R -e 'install.packages("BiocManager", repos="https://cloud.r-project.org")'
R -e 'BiocManager::install("Rcpp")'
R -e 'BiocManager::install("Rdisop")'

Indeed gives:

using C++ compiler: ‘clang version 14.0.5 (Fedora 14.0.5-2.fc36)’
/usr/bin/clang++ -std=gnu++17 -stdlib=libc++ -I"/tmp/R-devel/include" -DNDEBUG  -I'/tmp/R-devel/library/Rcpp/include' -I/usr/local/include   -I./imslib/src/ -fpic  -g -O2  -c disop.cpp -o disop.o
In file included from disop.cpp:22:
./imslib/src/ims/composedelement.h:204:58: error: no template named 'auto_ptr' in namespace 'std'
                void initializeElements(const Alphabet& alphabet, std::auto_ptr<sequence_parser_type> parser)
                                                                  ~~~~~^
In file included from disop.cpp:26:
./imslib/src/ims/decomp/realmassdecomposer.h:103:8: error: no template named 'auto_ptr' in namespace 'std'
                std::auto_ptr<integer_decomposer_type> decomposer;
                ~~~~~^
In file included from disop.cpp:28:
./imslib/src/ims/decomp/decomputils.h:74:80: error: no member named 'bind2nd' in namespace 'std'
        valuesRange.erase(std::remove_if(valuesRange.begin(), valuesRange.end(), std::bind2nd(std::less<T>(), 0)), valuesRange.end());
                                                                                 ~~~~~^
./imslib/src/ims/decomp/decomputils.h:81:80: error: no member named 'bind2nd' in namespace 'std'
        valuesRange.erase(std::remove_if(valuesRange.begin(), valuesRange.end(), std::bind2nd(std::less<T>(), 0)), valuesRange.end());
                                                                                 ~~~~~^
disop.cpp:325:6: error: use of undeclared identifier 'bind2nd'
                                        bind2nd(multiplies<abundance_type>(), scale));  // operation (*scale)
                                        ^
5 errors generated.
sneumann commented 1 year ago

Fixed in e87e53e8e4c8833a81d4c40d8c10c9b9f6b8b90d, available from BioC as 1.59.1 . Yours, Steffen