From ernest.turro at ic.ac.uk  Wed Jul 30 19:10:08 2008
From: ernest.turro at ic.ac.uk (Ernest Turro)
Date: Wed, 30 Jul 2008 18:10:08 +0100
Subject: [Rd] R, Macports and C++ streams
In-Reply-To: <52733F0E-88D3-4583-8FB9-816014FE0A47@r-project.org>
References: <37E1D80F-D1CB-4B4B-80B1-DDBDB0EF43BD@ic.ac.uk>
	<D5AE68F5-E80A-4E84-8988-039A3DF3A97F@epfl.ch>
	<ABDBB235-09CB-44F3-AE1C-BC7AC9BBCFAF@ic.ac.uk>
	<52733F0E-88D3-4583-8FB9-816014FE0A47@r-project.org>
Message-ID: <A8504049-3A5A-41F0-983F-222F049354A9@ic.ac.uk>


On 30 Jul 2008, at 17:58, Simon Urbanek wrote:

>
> On Jul 30, 2008, at 12:35 , Ernest Turro wrote:
>
>>
>> On 30 Jul 2008, at 15:18, Kjell Konis wrote:
>>
>>> I found this in Writing R Extensions:
>>>
>>> "Using C++ iostreams, as in this example, is best avoided. There  
>>> is no guarantee that the output will appear in the R console, and  
>>> indeed it will not on the R for Windows console. Use R code or the  
>>> C entry points (see Printing) for all I/O if at all possible."
>>>
>>> That is, use Rprintf() instead. The fact that your code works with  
>>> one version of gcc and not another can probably be chalked up to  
>>> coincidence.
>>>
>>
>> The doc warns that the output to stdout using iostreams may not  
>> appear on the console, there is no indication that doing this may  
>> crash R (and this has never happened to me before). Certainly, the  
>> use of file streams (fstreams) should work just fine.
>>
>
> FWIW I saw this problem when using mismatching compilers before  
> (long time ago when we had to use FSF-built gcc because of bugs in  
> Apple's gcc). Its likely cause is a combination of incompatible ABIs  
> and libstdc++ mismatch. Note that Apple's gcc build script goes into  
> great pains to not mess up system stdc++ because it's asking for  
> trouble.

Yes, this sounds like the most likely culprit. I guess, ultimately,  
Macports GCC maintainers should make sure their build script goes  
through the same hoops as Apple's to avoid this kind of mismatch  
problem with libstdc++. The best thing would be for the R port to  
depend on Apple-supplied gcc rather than the Macports gcc.

Cheers
Ernest


>
>
> Cheers,
> Simon
>
>
>>
>>
>>
>>> Kjell
>>>
>>> On Jul 30, 2008, at 3:45 PM, Ernest Turro wrote:
>>>
>>>> Dear all,
>>>>
>>>> R on Macports relies on GCC 4.3 to build packages. I find that
>>>> packages with shared objects that use C++ streams crash R if  
>>>> they're
>>>> compiled using Macports' gcc43, but work fine if compiled in  
>>>> exactly
>>>> the same way using Apple-supplied GCC 4.2. Has anyone here had the
>>>> same issue/know what is causing this problem?
>>>>
>>>> Thanks,
>>>>
>>>> Ernest
>>>>
>>>> ______________________________________________
>>>> R-devel at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>



[Rd] R, Macports and C++ streams
Ernest Turro