Hello Davor,<br><br>Yes, I think - I have:<br>#ifndef HEADERNAME_IN_CAPS<br>#define HEADERNAME_IN_CAPS 1<br>(..code..)<br>#endif<br>for all my headers.<br><br>As far as I can tell the problem arises when fstream includes <div class="h5">
codecvt.h, which calls, on line 42:<br></div><br>_GLIBCXX_BEGIN_NAMESPACE(std)<br><br>I don&#39;t think this pertains to my own header includes, but I could very well be wrong.<br><br>Thanks,<br><br>Simon<br><br><br><div class="gmail_quote">
On Tue, Oct 11, 2011 at 5:27 AM, Davor Cubranic <span dir="ltr">&lt;<a href="mailto:cubranic@stat.ubc.ca">cubranic@stat.ubc.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Simon,<br>
<br>
Are you wrapping your header file with an #ifndef to prevent it from being<br>
included multiple times?<br>
<br>
Davor<br>
<div><div></div><div class="h5"><br>
<br>
On October 10, 2011 03:01:33 PM Simon Fuller wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I am getting some problems further down the line. It seems to happen when I<br>
&gt; am including a std header in my own class, and when it itself includes a<br>
&gt; header. Which suggests the problem is not with including headers in<br>
&gt; general.<br>
&gt;<br>
&gt; When it is reading my header, it gets this error in fstream:<br>
&gt;<br>
&gt; In file included from /usr/include/c++/4.5/fstream:42:0,<br>
&gt;                  from<br>
&gt; /home/simon/College/PackageOne/src/MyClass/MyClass.h:6,<br>
&gt;                  from file8ffc305.cpp:37:<br>
&gt; /usr/include/c++/4.5/bits/codecvt.h: In function ‘SEXPREC*<br>
&gt; file8ffc305(SEXPREC*, SEXPREC*)’:<br>
&gt; /usr/include/c++/4.5/bits/codecvt.h:42:1: error: expected ‘=’ before<br>
&gt; ‘__attribute__’<br>
&gt; /usr/include/c++/4.5/bits/codecvt.h:42:1: error: expected identifier before<br>
&gt; ‘__attribute__’<br>
&gt; /usr/include/c++/4.5/bits/codecvt.h:42:1: error: expected ‘;’ before<br>
&gt; ‘__attribute__’<br>
&gt; /usr/include/c++/4.5/bits/codecvt.h:42:1: error: expected<br>
&gt; primary-expression before ‘__attribute__’<br>
&gt; /usr/include/c++/4.5/bits/codecvt.h:42:1: error: expected ‘;’ before<br>
&gt; ‘__attribute__’<br>
&gt;<br>
&gt; In fstream, line 42 is indeed: #include &lt;bits/codecvt.h&gt;<br>
&gt;<br>
&gt; I checked /usr/include/c++/4.5/bits/codecvt.h:42:1:<br>
&gt;<br>
&gt; and this is line 42 of codecvt.h:<br>
&gt;<br>
&gt; _GLIBCXX_BEGIN_NAMESPACE(std)<br>
&gt;<br>
&gt; I googled this function, and I am wondering if it might be a compatibility<br>
&gt; issue, as this sometimes seems to be cited in this regard in forums. I<br>
&gt; really do not know myself. Has anyone any suggestions?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Simon<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Oct 10, 2011 at 11:09 AM, Simon Fuller<br>
&gt; &lt;<a href="mailto:simonfuller9@gmail.com">simonfuller9@gmail.com</a>&gt;wrote:h<br>
&gt;<br>
&gt; &gt; Hello,<br>
&gt; &gt;<br>
&gt; &gt; I have just joined the mailing list.<br>
&gt; &gt;<br>
&gt; &gt; I was hoping you might be able to help me with a question.<br>
&gt; &gt;<br>
&gt; &gt; I am new to Rcpp, have some experience with both R and C++, but very<br>
&gt; &gt; little experience with integrating languages.<br>
&gt; &gt;<br>
&gt; &gt; I hope to use Rcpp to develop code over the next few years. However, to<br>
&gt; &gt; begin with, I have some preexisting C++ classes that I would like to make<br>
&gt; &gt; available to R.<br>
&gt; &gt;<br>
&gt; &gt; I have read the documentation that I can find, but I do not know which is<br>
&gt; &gt; the best approach to take.<br>
&gt; &gt;<br>
</div></div>&gt; &gt; I only, in principle, need *one method* to interact with the classes -<br>
<div><div></div><div class="h5">&gt; &gt; there then follows a fairly arduous process using different tree<br>
&gt; &gt; structures each of which have aggregate classes, but only a single<br>
&gt; &gt; double needs to be returned to R.<br>
&gt; &gt;<br>
&gt; &gt; I was therefore hoping to simply call a C++ wrapper function in-line,<br>
&gt; &gt; remotely, which in turn called my classes, but that does not work. I get<br>
&gt; &gt; an: &quot;expected unqualified-id before ‘extern’ &quot; error after my includes,<br>
&gt; &gt; at: RcppExport SEXP..  at the start of my method declaration. (I can<br>
&gt; &gt; post code if this approach is not a complete dead end)<br>
&gt; &gt;<br>
&gt; &gt; So my two questions are: is there a quick way of prototyping this? i.e.<br>
&gt; &gt; to get R to invoke my classes through an rcpp intermediary.<br>
&gt; &gt;<br>
&gt; &gt; If there is not a quick way to do this, what is the best approach? Do I<br>
&gt; &gt; need to, and if so how do I, make my classes accessible to Rcpp. Because<br>
&gt; &gt; my whole hope here is to use preexisting code as swiftly as possible,<br>
&gt; &gt; &#39;easiest&#39; and &#39;quickest&#39; are almost synonyms for &#39;best&#39; in my question.<br>
&gt; &gt;<br>
&gt; &gt; If someone could point me in the direction of some example code where<br>
&gt; &gt; Rcpp invokes user classes this would be great.<br>
&gt; &gt;<br>
&gt; &gt; My apologies if my question has been covered before, but I would really<br>
&gt; &gt; appreciate some advice on what is and is not possible, and some strategic<br>
&gt; &gt; advice on the best (easiest and quickest) approach.<br>
&gt; &gt;<br>
&gt; &gt; Thank you for your help. It is deeply appreciated.<br>
&gt; &gt;<br>
&gt; &gt; Simon<br>
</div></div></blockquote></div><br>