[Rcpp-devel] Clang 3.0 and 3.3 errors on sugar/set.h
Romain Francois
romain at r-enthusiasts.com
Mon Nov 19 23:57:28 CET 2012
The thing about #elseif has been fixed on the development version a few days ago. Can you try again with the scn version of rcpp ?
Also, if you use c++11 features, you are on your own. We will happily do c++11 code when we get some sort of green light from cran, which might take years.
Romain
Le 19 nov. 2012 à 18:22, Thell Fowler <tbfowler4 at gmail.com> a écrit :
> First:: Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
>
> >> setting environment variables:
> PKG_LIBS = -lmpfr -lgmp -L/home/thell/R/library/Rcpp/lib -lRcpp -Wl,-rpath,/home/thell/R/library/Rcpp/lib
> PKG_CPPFLAGS = -std=c++11
>
> >> LinkingTo : Rcpp
> CLINK_CPPFLAGS = -I"/home/thell/R/library/Rcpp/include"
>
> >> Program source :
>
> 1 :
> 2 : // includes from the plugin
> 3 :
> 4 : #include <cmath>
> 5 : #include <iterator>
> 6 : #include <RcppCommon.h>
> 7 : #include <mpreal.h>
> 8 :
> 9 : namespace Rcpp {
> 10 : template <> SEXP wrap( const mpfr::mpreal& ) ;
> 11 : }
> 12 :
> 13 : #include <Rcpp.h>
> 14 :
> 15 : // Definitions from Rmpfr conversion utilities.
> 16 : #if GMP_NUMB_BITS == 32
> 17 :
> 18 : # define R_mpfr_nr_ints nr_limbs
> 19 : # define R_mpfr_exp_size 1
> 20 :
> 21 : #elif GMP_NUMB_BITS == 64
> 22 :
> 23 : # define R_mpfr_nr_ints (2*nr_limbs)
> 24 : # define R_mpfr_exp_size 2
> 25 :
> 26 : #endif
> 27 :
> 28 : # define RIGHT_HALF(_LONG_) ((long long)(_LONG_) & 0x00000000FFFFFFFF)
> 29 : # define LEFT_SHIFT(_LONG_) (((long long)(_LONG_)) << 32)
> 30 :
> 31 : namespace Rcpp {
> 32 :
> 33 : template<> SEXP wrap( const mpfr::mpreal& v )
> 34 : {
> 35 : mpfr_srcptr pv( v.mpfr_srcptr() );
> 36 :
> 37 : S4 vS4("mpfr1");
> 38 : vS4.slot("prec") = wrap( (int)pv->_mpfr_prec );
> 39 : vS4.slot("sign") = wrap( (int)pv->_mpfr_sign);
> 40 :
> 41 : IntegerVector d( std::ceil( (double)pv->_mpfr_prec / (double)mp_bits_per_limb ) );
> 42 : mp_size_t i = 0;
> 43 :
> 44 : if( GMP_NUMB_BITS == 32 ) {
> 45 :
> 46 : vS4.slot("exp") = wrap( (int)pv->_mpfr_exp );
> 47 :
> 48 : for( auto & e : d ) {
> 49 : e = (int) pv->_mpfr_d[i];
> 50 : ++i;
> 51 : }
> 52 :
> 53 : } else {
> 54 :
> 55 : IntegerVector exp(2);
> 56 : exp[0] = (int) RIGHT_HALF(pv->_mpfr_exp);
> 57 : exp[1] = (int) (pv->_mpfr_exp >> 32);
> 58 : vS4.slot("exp") = exp;
> 59 :
> 60 : for(i=0; i < d.size(); i++) {
> 61 : d[2*i] = (int) RIGHT_HALF(pv->_mpfr_d[i]);
> 62 : d[2*i+1]= (int) (pv->_mpfr_d[i] >> 32);
> 63 : }
> 64 :
> 65 : }
> 66 :
> 67 : vS4.slot("d") = d;
> 68 : return vS4;
> 69 : }
> 70 :
> 71 : }
> 72 :
> 73 :
> 74 : #ifndef BEGIN_RCPP
> 75 : #define BEGIN_RCPP
> 76 : #endif
> 77 :
> 78 : #ifndef END_RCPP
> 79 : #define END_RCPP
> 80 : #endif
> 81 :
> 82 : using namespace Rcpp;
> 83 :
> 84 :
> 85 : // user includes
> 86 :
> 87 :
> 88 :
> 89 : // declarations
> 90 : extern "C" {
> 91 : SEXP file34e23fb9ce5( SEXP x, SEXP prec) ;
> 92 : }
> 93 :
> 94 : // definition
> 95 :
> 96 : SEXP file34e23fb9ce5( SEXP x, SEXP prec ){
> 97 : BEGIN_RCPP
> 98 :
> 99 : using namespace mpfr;
> 100 : using namespace Rcpp;
> 101 :
> 102 : mpreal::set_default_prec( as< unsigned long >( prec ) );
> 103 : return wrap( fac_ui( as< double >( x ) ) );
> 104 :
> 105 : END_RCPP
> 106 : }
> 107 :
> 108 :
> Compilation argument:
> /usr/lib/R/bin/R CMD SHLIB file34e23fb9ce5.cpp 2> file34e23fb9ce5.cpp.err.txt
> "/usr/bin/clang++" -I/usr/share/R/include -DNDEBUG -std=c++11 -I"/home/thell/R/library/Rcpp/include" -fpic -O3 -pipe -g -c file34e23fb9ce5.cpp -o file34e23fb9ce5.o
> In file included from file34e23fb9ce5.cpp:13:
> In file included from /home/thell/R/library/Rcpp/include/Rcpp.h:68:
> In file included from /home/thell/R/library/Rcpp/include/Rcpp/sugar/sugar.h:25:
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:28:2: error: invalid preprocessing directive
> #elseif defined(HAS_TR1_UNORDERED_SET)
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:29:13: warning: 'RCPP_UNIQUE_SET' macro redefined
> #define RCPP_UNIQUE_SET std::tr1::unordered_set
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:26:13: note: previous definition is here
> #define RCPP_UNIQUE_SET std::unordered_set
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:30:13: warning: 'RCPP_UNIQUE_MAP' macro redefined
> #define RCPP_UNIQUE_MAP std::tr1::unordered_map
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:27:13: note: previous definition is here
> #define RCPP_UNIQUE_MAP std::unordered_map
> ^
> file34e23fb9ce5.cpp:57:31: warning: shift count >= width of type [-Wshift-count-overflow]
> exp[1] = (int) (pv->_mpfr_exp >> 32);
> ^ ~~
> file34e23fb9ce5.cpp:62:33: warning: shift count >= width of type [-Wshift-count-overflow]
> d[2*i+1]= (int) (pv->_mpfr_d[i] >> 32);
> ^ ~~
> 4 warnings and 1 error generated.
> make: *** [file34e23fb9ce5.o] Error 1
>
> ERROR(s) during compilation: source code errors or compiler configuration errors!
>
> ================================
> Now:: clang version 3.3 (http://llvm.org/git/clang.git 86256af6c8515077278d0a78f183fb6d322518ac) (http://llvm.org/git/llvm.git 8f54a53f0ed2091e05d5ca87d239487da292cbbc)
>
> >> setting environment variables:
> PKG_LIBS = -lmpfr -lgmp -L/home/thell/R/library/Rcpp/lib -lRcpp -Wl,-rpath,/home/thell/R/library/Rcpp/lib
> PKG_CPPFLAGS = -std=c++11
>
> >> LinkingTo : Rcpp
> CLINK_CPPFLAGS = -I"/home/thell/R/library/Rcpp/include"
>
> >> Program source :
>
> 1 :
> 2 : // includes from the plugin
> 3 :
> 4 : #include <cmath>
> 5 : #include <iterator>
> 6 : #include <RcppCommon.h>
> 7 : #include <mpreal.h>
> 8 :
> 9 : namespace Rcpp {
> 10 : template <> SEXP wrap( const mpfr::mpreal& ) ;
> 11 : }
> 12 :
> 13 : #include <Rcpp.h>
> 14 :
> 15 : // Definitions from Rmpfr conversion utilities.
> 16 : #if GMP_NUMB_BITS == 32
> 17 :
> 18 : # define R_mpfr_nr_ints nr_limbs
> 19 : # define R_mpfr_exp_size 1
> 20 :
> 21 : #elif GMP_NUMB_BITS == 64
> 22 :
> 23 : # define R_mpfr_nr_ints (2*nr_limbs)
> 24 : # define R_mpfr_exp_size 2
> 25 :
> 26 : #endif
> 27 :
> 28 : # define RIGHT_HALF(_LONG_) ((long long)(_LONG_) & 0x00000000FFFFFFFF)
> 29 : # define LEFT_SHIFT(_LONG_) (((long long)(_LONG_)) << 32)
> 30 :
> 31 : namespace Rcpp {
> 32 :
> 33 : template<> SEXP wrap( const mpfr::mpreal& v )
> 34 : {
> 35 : mpfr_srcptr pv( v.mpfr_srcptr() );
> 36 :
> 37 : S4 vS4("mpfr1");
> 38 : vS4.slot("prec") = wrap( (int)pv->_mpfr_prec );
> 39 : vS4.slot("sign") = wrap( (int)pv->_mpfr_sign);
> 40 :
> 41 : IntegerVector d( std::ceil( (double)pv->_mpfr_prec / (double)mp_bits_per_limb ) );
> 42 : mp_size_t i = 0;
> 43 :
> 44 : if( GMP_NUMB_BITS == 32 ) {
> 45 :
> 46 : vS4.slot("exp") = wrap( (int)pv->_mpfr_exp );
> 47 :
> 48 : for( auto & e : d ) {
> 49 : e = (int) pv->_mpfr_d[i];
> 50 : ++i;
> 51 : }
> 52 :
> 53 : } else {
> 54 :
> 55 : IntegerVector exp(2);
> 56 : exp[0] = (int) RIGHT_HALF(pv->_mpfr_exp);
> 57 : exp[1] = (int) (pv->_mpfr_exp >> 32);
> 58 : vS4.slot("exp") = exp;
> 59 :
> 60 : for(i=0; i < d.size(); i++) {
> 61 : d[2*i] = (int) RIGHT_HALF(pv->_mpfr_d[i]);
> 62 : d[2*i+1]= (int) (pv->_mpfr_d[i] >> 32);
> 63 : }
> 64 :
> 65 : }
> 66 :
> 67 : vS4.slot("d") = d;
> 68 : return vS4;
> 69 : }
> 70 :
> 71 : }
> 72 :
> 73 :
> 74 : #ifndef BEGIN_RCPP
> 75 : #define BEGIN_RCPP
> 76 : #endif
> 77 :
> 78 : #ifndef END_RCPP
> 79 : #define END_RCPP
> 80 : #endif
> 81 :
> 82 : using namespace Rcpp;
> 83 :
> 84 :
> 85 : // user includes
> 86 :
> 87 :
> 88 :
> 89 : // declarations
> 90 : extern "C" {
> 91 : SEXP file34e215a2f7e7( SEXP x, SEXP prec) ;
> 92 : }
> 93 :
> 94 : // definition
> 95 :
> 96 : SEXP file34e215a2f7e7( SEXP x, SEXP prec ){
> 97 : BEGIN_RCPP
> 98 :
> 99 : using namespace mpfr;
> 100 : using namespace Rcpp;
> 101 :
> 102 : mpreal::set_default_prec( as< unsigned long >( prec ) );
> 103 : return wrap( fac_ui( as< double >( x ) ) );
> 104 :
> 105 : END_RCPP
> 106 : }
> 107 :
> 108 :
> Compilation argument:
> /usr/lib/R/bin/R CMD SHLIB file34e215a2f7e7.cpp 2> file34e215a2f7e7.cpp.err.txt
> "clang++" -I/usr/share/R/include -DNDEBUG -std=c++11 -I"/home/thell/R/library/Rcpp/include" -fpic -O3 -pipe -g -c file34e215a2f7e7.cpp -o file34e215a2f7e7.o
> In file included from file34e215a2f7e7.cpp:6:
> In file included from /home/thell/R/library/Rcpp/include/RcppCommon.h:349:
> In file included from /home/thell/R/library/Rcpp/include/Rcpp/sugar/sugar_forward.h:29:
> In file included from /home/thell/R/library/Rcpp/include/Rcpp/sugar/logical/logical.h:27:
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/logical/SingleLogicalResult.h:36:2: error: circular inheritance between 'conversion_to_bool_is_forbidden<x>' and 'conversion_to_bool_is_forbidden<x>'
> conversion_to_bool_is_forbidden<x>{
> ^
> In file included from file34e215a2f7e7.cpp:13:
> In file included from /home/thell/R/library/Rcpp/include/Rcpp.h:68:
> In file included from /home/thell/R/library/Rcpp/include/Rcpp/sugar/sugar.h:25:
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:28:2: error: invalid preprocessing directive
> #elseif defined(HAS_TR1_UNORDERED_SET)
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:29:13: warning: 'RCPP_UNIQUE_SET' macro redefined
> #define RCPP_UNIQUE_SET std::tr1::unordered_set
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:26:13: note: previous definition is here
> #define RCPP_UNIQUE_SET std::unordered_set
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:30:13: warning: 'RCPP_UNIQUE_MAP' macro redefined
> #define RCPP_UNIQUE_MAP std::tr1::unordered_map
> ^
> /home/thell/R/library/Rcpp/include/Rcpp/sugar/sets.h:27:13: note: previous definition is here
> #define RCPP_UNIQUE_MAP std::unordered_map
> ^
> file34e215a2f7e7.cpp:57:31: warning: shift count >= width of type [-Wshift-count-overflow]
> exp[1] = (int) (pv->_mpfr_exp >> 32);
> ^ ~~
> file34e215a2f7e7.cpp:62:33: warning: shift count >= width of type [-Wshift-count-overflow]
> d[2*i+1]= (int) (pv->_mpfr_d[i] >> 32);
> ^ ~~
> 4 warnings and 2 errors generated.
> make: *** [file34e215a2f7e7.o] Error 1
>
> ERROR(s) during compilation: source code errors or compiler configuration errors!
>
>
> The code compiles and works (the warnings are expected for now) using g++.
> --
> Sincerely,
> Thell
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121119/ef04b46c/attachment-0001.html>
More information about the Rcpp-devel
mailing list