[R] Compiling only some C files
Duncan Murdoch
murdoch at stats.uwo.ca
Mon Aug 11 22:03:02 CEST 2008
Barry Rowlingson wrote:
> 2008/8/11 Lafaye de Micheaux Pierre
> <Pierre.Lafaye-de-Micheaux at upmf-grenoble.fr>:
>
>> Thank you Barry,
>>
>> In fact, these are only C files (not C++) and i use the extern "C"
>> directive.
>>
>> I would prefer not to rename the files because many of these files serve
>> also in other projects where they should have the .cpp extension
>> I would also not like to merge all the *.cpp files in one unique file
>> because many users have to provide their own C file.
>>
>> So i would really like to use some kind of configure or Make script, that
>> should be put in the source directory tree of the R package.
>>
>
> If the only function of these files within the R package in question
> is to be included into the other C++ files, then perhaps you could put
> them in another directory and include them from there:
>
> #include "../extrasrc/foo.cpp"
>
> I'm not sure if the forward slash will work in non-Unix OSs, but it might...
>
Yes, it's fine on all the R platforms.
One reason to include a .cpp file is when it's code written by someone
else. For example, the rgl package makes use of the ftgl library, and
includes it in source form, with a bunch of #include's from a
subdirectory to pick out the needed parts. This way no changes to
ftgl need to be made to suit rgl.
Duncan Murdoch
> There may be some make-magic to tell make to exclude some files from
> its implicit build rules, but I don't know what it is.
>
> Barry
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list