(rebrand as a Rcpp-devel question)

Le 19/09/13 13:58, Romain Francois a écrit :
Hello,

I'm trying to understand these:

#ifdef __GNUC__
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) &&
defined(__LP64__))
#ifdef __LONG_LONG_MAX__
     __extension__ typedef long long int rcpp_long_long_type;
     __extension__ typedef unsigned long long int rcpp_ulong_long_type;
     #define RCPP_HAS_LONG_LONG_TYPES
#endif
#endif
#endif


On my system, I have :

 > demangle( "long long" )
[1] "long long"
 > sizeof( "long long" )
8 bytes (64 bits)

So I do have a long long type. But I'm not running with c++0x or clang,
so I don't get the macro defined:

 > Rcpp:::areMacrosDefined( "RCPP_HAS_LONG_LONG_TYPES" )
RCPP_HAS_LONG_LONG_TYPES
                    FALSE

That feels wrong. Maybe we could use some sort of configure script with

AC_CHECK_SIZEOF(long long)

I don't get why we have this line:

#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) &&
defined(__LP64__))

Isn't having __LONG_LONG_MAX__ enough ?

long long has nothing to do with C++11.

Romain

And if compile this file with -Wall -pedantic. I don't get issues:

#include <Rcpp.h>
using namespace Rcpp ;

__extension__ typedef long long int rcpp_long_long_type;

// [[Rcpp::export]]
int foo(){
        rcpp_long_long_type x = 2 ;
        return (int)x;
}


But if I remove the __extension__ thing, I get the warning:

$ RcppScript longlong.cpp
longlong.cpp:4: error: ISO C++ does not support ‘long long’
make: *** [longlong.o] Error 1
llvm-g++-4.2 -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include" -Wall -pedantic -fPIC -mtune=core2 -g -O2 -c longlong.cpp -o longlong.o
Erreur dans sourceCpp(file) : Error 1 occurred building shared library.
Exécution arrêtée

-pedantic gives us the warning when it sees us writing long long, but if we just hide it behind __extension__ it does not complain no more.


So we should be able to just use __LONG_LONG_MAX__ and if people want to use long long in their code, they use rcpp_long_long_type or maybe we alias it to something sweater (LONG_LONG) perhaps ?


Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to