[Rcpp-devel] Defining template specialisation for wrap on Windows 64bit (Compilation error: 'result_type' does not name a type)

Renaud Gaujoux renaud at mancala.cbio.uct.ac.za
Fri Oct 4 14:32:02 CEST 2013


Thanks for popping in Steve. I was full of hope when I read your reply!
Unfortunately I could not solve the issue with the changes you suggested.


> I believe the correct syntax for the specialization is
>
>         template <> octave_value as<octave_value>( SEXP );
>

This declaration works as fine on Linux as the one omitting
"<octave_value>". No luck on Windows though (but see below)

> but one cannot write:
> SEXP sx;
> octave_value ov = as(sx); // type deduction applies only to arguments,
not return value!
>
> // correct:
> // ov = as<octave_value>(sx);

yes, this makes completely sense, and this is how I indeed call the
template function.

I reduced the code even more and actually get the same errors even without
declaring any template specialisation, but just including <Rcpp.h>! See
code below.
I don't see why only including the headers in sequence breaks compilation,
since we are not even defining .
The first reported error occurs in include/Rcpp/Language.h, in the
following class, where 'result_type' is defined by typdef:

    template <typename OUT=SEXP>
    class fixed_call {
    public:
        *typedef OUT result_type ;*

        fixed_call( Language call_ ) : call(call_){}
        fixed_call( Function fun ) : call(fun){}

        OUT operator()(){
            return as<OUT>( call.eval() ) ;
        }

    private:
        Language call ;
    } ;


This got me thinking and googling for this more general error (see next
email). Yeah!!

Renaud


##############
// Single file rcpp_octave.cpp

// RcppCommon
#include <RcppCommon.h>
// Octave libraries
#include <octave/config.h>
#include <octave/ov.h>
// Rcpp
#include <Rcpp.h>


void dummy(){

}

###
Compilation log (I managed to force gcc to stop after 10 errors: I learnt
something today):

** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

g++ -m32 -I"c:/R/R-3.0.2/include" -DNDEBUG
-IC:/R/R-3.0.2/library/Rcpp/include -fmax-errors=10 -Wall
-DOCT_POST_3_4_0=1 -I"C:\Octave\Octave3.6.4_gcc4.6.2\include"
-I"C:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave"
-I"C:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave/../"
-I"c:/R/R-3.0.2/library/Rcpp/include"
-I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall
 -mtune=core2 -c rcpp_octave.cpp -o rcpp_octave.o

In file included from rcpp_octave.cpp:24:0:
C:\Octave\Octave3.6.4_gcc4.6.2\include\octave-3.6.4\octave/../octave/config.h:2764:0:
warning: "_WIN32_WINNT" redefined [enabled by default]
c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/_mingw.h:244:0:
note: this is the location of the previous definition In file included from
C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:50:0,
                 from rcpp_octave.cpp:27:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:156:21: error:
'result_type' does not name a type
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:161:24: error: ISO C++
forbids declaration of 'operator()' with no type [-fpermissive]
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member function 'int
Rcpp::fixed_call< <template-parameter-1-1> >::operator()()':
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41: error: no
matching function for call to 'as(SEXPREC*&)'
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41: note: candidate
is:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note: template<class T>
T Rcpp::as(SEXP)
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: At global scope:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:170:56: error: template
argument 2 is invalid
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:176:41: error: ISO C++
forbids declaration of 'operator()' with no type [-fpermissive]
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member function 'int
Rcpp::unary_call<T, <template-parameter-1-2> >::operator()(const
T&)':
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:178:41: error: no
matching function for call to 'as(SEXPREC*&)'
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:178:41: note: candidate
is:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note: template<class T>
T Rcpp::as(SEXP)
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: At global scope:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:187:62: error: template
argument 3 is invalid
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:193:52: error: ISO C++
forbids declaration of 'operator()' with no type [-fpermissive]
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member function 'int
Rcpp::binary_call<T1, T2, <template-parameter-1-3> >::operator()(
const T1&, const T2&)':
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:196:41: error: no
matching function for call to 'as(SEXPREC*&)'
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:196:41: note: candidate
is:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/as.h:144:29: note: template<class T>
T Rcpp::as(SEXP)
In file included from C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Module.h:85:0,
                 from C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:63,
                 from rcpp_octave.cpp:27:
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/module/Module_generated_get_return_type.h:
In function 'std::string Rcpp::get_return_type_dispatch(Rc
pp::traits::false_type)':
C:/R/R-3.0.2/library/Rcpp/include/Rcpp/module/Module_generated_get_return_type.h:29:32:
error: expected primary-expression before ')' token
compilation terminated due to -fmax-errors=10.
make: *** [rcpp_octave.o] Error 1
ERROR: compilation failed for package 'RcppOctave'
* removing 'Z:/projects/RcppOctave/libwin/RcppOctave'
* restoring previous 'Z:/projects/RcppOctave/libwin/RcppOctave'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131004/7802e214/attachment.html>


More information about the Rcpp-devel mailing list