[Rcpp-commits] r1854 - deprecated

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 13 13:21:22 CEST 2010


Author: romain
Date: 2010-07-13 13:21:21 +0200 (Tue, 13 Jul 2010)
New Revision: 1854

Added:
   deprecated/cxx0x.R
Log:
moving the cxx0x.R script to deprecated

Copied: deprecated/cxx0x.R (from rev 1852, pkg/Rcpp/src/cxx0x/cxx0x.R)
===================================================================
--- deprecated/cxx0x.R	                        (rev 0)
+++ deprecated/cxx0x.R	2010-07-13 11:21:21 UTC (rev 1854)
@@ -0,0 +1,57 @@
+#!/bin/env Rscript
+
+# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+local({
+	flag <- function(){
+		
+		cxx0x.code <- '
+		#include <R.h>
+		#include <Rdefines.h>
+		
+		extern "C" SEXP cxx0x(){
+		
+		#ifdef __GNUC__
+			#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+			#if GCC_VERSION >= 40300
+			return mkString( "-std=c++0x" ) ;
+			#endif
+		#endif
+		return mkString( "" ) ;
+		}
+		'
+		td <- tempfile()
+		dir.create( td )
+		here <- getwd()
+		setwd(td)
+		dll <- sprintf( "cxx0x%s", .Platform$dynlib.ext )
+		on.exit( { 
+			dyn.unload( dll )
+			setwd(here) ; 
+			unlink( td, recursive = TRUE )
+		} )
+		writeLines( cxx0x.code, "cxx0x.cpp" )
+		cmd <- sprintf( '"%s/R" CMD SHLIB cxx0x.cpp', R.home(component="bin") )
+		system( cmd, intern = TRUE )
+		dyn.load( dll )
+		res <- tryCatch( .Call( "cxx0x" ), error = "" )
+		res
+	}
+	cat( flag() )
+})
+



More information about the Rcpp-commits mailing list