[Rcpp-devel] package with module not compiling on Mac
Romain Francois
romain at r-enthusiasts.com
Thu Jan 31 12:38:33 CET 2013
Le 31/01/13 12:15, Robin Girard a écrit :
> Merci Romain !
>
> I am doing this to make possible a direct use of the result such as in A=Sum(f1.Swap(0),f2.Etoile())
I see. I figured you were using some sort of chaining. I'm not a big fan
of methods that return a reference to the object they are working on,
but I understand the appeal.
I find this:
A=Sum(f1.Swap(0),f2.Etoile())
less clear than :
f1.Swap(0)
f2.Etoile()
A=Sum(f1,f2)
Matter of taste perhaps. Anyway this is not supported.
> This is not really necessary but sometime convenient. That's old prog souvenirs for me so please correct me if this is stupid.
Not stupid, just not supported.
> Can it be that my clone is wrong ? (indeed I am not sure to really understand how it works)
>
> cplfunction* clone(){
> return new cplfunction() ;
> }
If you wanted "clone" to make a new object using the default
constructor, then that is what it does. In that case, that is a very odd
naming choice.
You probably should use the copy constructor instead, e.g. something
like this:
cplfunction* clone() const {
return new cplfunction(*this) ;
}
Going further:
- I don't think you need the finalizer and I believe what you are doing
will end up trying to delete the object twice. Our finalizers are for
things that are not done by the destructor. We call the finalizer and
then the destructor IIRC.
- I think your default constructor is wrong:
cplfunction(){
map<double,double> Breakpoints_;
FirstBreakVal_=0;
}
You are here creating a local variable Breakpoints_ when I think you
wanted to initialize the class member. Something like this looks better:
cplfunction() : Breakpoints_(), FirstBreakVal_(0){}
This is not a full review, just a few things that I found odd while
looking at your code. (It took me more time to write this email than
finding these odd :-) ).
Romain
> I will try to make it by adapting the two functions and their use !
> Robin
>
>
> ----- Mail original -----
> De: "Romain Francois" <romain at r-enthusiasts.com>
> À: rcpp-devel at lists.r-forge.r-project.org
> Envoyé: Jeudi 31 Janvier 2013 11:52:19
> Objet: Re: [Rcpp-devel] package with module not compiling on Mac
>
> Hello,
>
> I can reproduce the compiler error on my mac. If I comment the methods
> Swap and Etoile, then I can compile the package.
>
> Now looking at the signatures:
>
> cplfunction & Swap(double y) ;
> cplfunction & Etoile() ;
>
> I think the problem is that they return a reference. Looking at their
> code, it looks like they only ever return *this. Why are you doing this ?
>
> I'd suggest you return void.
>
> Romain
>
> Le 29/01/13 16:04, Robin Girard a écrit :
>>
>> The Mac version of my package http://cran.r-project.org/web/packages/ConConPiWiFun/index.html
>> (using Rcpp module) does not compile.
>> the error message is here
>> http://www.r-project.org/nosvn/R.check/r-release-macosx-ix86/ConConPiWiFun-00install.html
>>
>> and contains "no matching function for call to 'module_wrap(cplfunction&)'" does it means that I might have called things in the wrong order in my cpp code ?
>>
>> my cpp code starts like that
>> #include <map>
>> #include <math.h>
>> #include <limits>
>> #include <Rcpp.h>
>>
>> using namespace std;
>> using namespace Rcpp;
>> class cplfunction ;
>> RCPP_EXPOSED_CLASS(cplfunction)
>>
>>
>> is there something like win-builder but for mac ?
>>
>> All the best
>> Robin
>>
>> Dr. Girard Robin
>> Chargé de Recherche
>>
>> MINES-ParisTech / Département Energétique et Procédés / PERSEE / Groupe ERSEI
>> Centre Procédés, Energies Renouvelables et Systèmes Energétiques (PERSEE)
>> Center for Processes, Renewables Energies and Energy Systems
>> Renewable Energies & Smartgrids (ERSEI)
>>
>> 1 Rue Claude Daunesse - CS 10207 - F-06904 Sophia Antipolis Cedex
>> Tel: +33.4.93.67.89.64 (~99), Fax: +33.4.93.95.75.35
>> e-mail : robin.girard at mines-paristech.fr
>>
>> web page perso http://www.mines-paristech.fr/Services/Annuaire/&?id=8828
>> statoverflow : http://stats.stackexchange.com/users/223/robin-girard
>> web page centre PERSEE : http://www.cep.mines-paristech.fr/
>> linkedin : http://www.linkedin.com/profile/view?id=14907272&trk=tab_pro
>>
>> Le lien vaut mieux que le bien.
>> ________________________________________________________
>>
>> CONFIDENTIALITY : This e-mail and any attachments are
>> confidential and may be privileged. If you are not a
>> named recipient, please notify the sender immediately and
>> do not disclose the contents to another person, use it for
>> any purpose or store or copy the information in any medium.
>>
>> CONFIDENTIALITE : Ce message et les éventuelles pièces
>> attachées sontconfidentiels et peuvent être une
>> communication protégée. Si vous n'êtes pas dans la liste
>> des destinataires, veuillez informer l'expéditeur
>> immédiatement et ne pas ouvrir ni divulguer le contenu
>> à une tierce personne, ne pas l'utiliser pour quelque
>> raison que ce soit, ne pas stocker ou copier l'information
>> qu'il contient sur un quelconque support.
>>
>> _______________________________________________
>> 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
>>
>
>
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
blog: http://romainfrancois.blog.free.fr
|- http://bit.ly/RE6sYH : OOP with Rcpp modules
`- http://bit.ly/Thw7IK : Rcpp modules more flexible
More information about the Rcpp-devel
mailing list