Skip to content

long long warnings in algorithm.h #502

@nathan-russell

Description

@nathan-russell

Per @dcdillon's comment in #501,

The long long warnings are puzzling as all references to long long seem to be wrapped in ifdefs appropriately

in reference to @thirdwing's compiler output,

* checking whether package ‘with.dot’ can be installed ... WARNING
Found the following significant warnings:
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include/Rcpp/algorithm.h:48:62: warning: 'long long' is a C++11 extension [-Wc++11-long-long] 
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include/Rcpp/algorithm.h:77:80: warning: 'long long' is a C++11 extension [-Wc++11-long-long]   
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include/Rcpp/algorithm.h:89:43: warning: 'long long' is a C++11 extension [-Wc++11-long-long] 
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include/Rcpp/algorithm.h:100:61: warning: 'long long' is a C++11 extension [-Wc++11-long-long] 
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include/Rcpp/algorithm.h:117:43: warning: 'long long' is a C++11 extension [-Wc++11-long-long]   
/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include/Rcpp/algorithm.h:128:61: warning: 'long long' is a C++11 extension [-Wc++11-long-long] 

I have also been experiencing this with more recent versions of Rcpp (since the addition of algorithm.h). As far as I can tell, this only happens when compiling with clang and passing the -pedantic flag:

devtools::install_github("RcppCore/Rcpp") 

clang++ -I/usr/share/R/include -DNDEBUG -I../inst/include/ \   
-fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 \
-Wformat -Wall -pedantic -Werror=format-security -D_FORTIFY_SOURCE=2 \
-g  -c Date.cpp -o Date.o

In file included from Date.cpp:31:
In file included from ../inst/include/Rcpp.h:84:
../inst/include/Rcpp/algorithm.h:48:62: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
    struct ctype_helper< sizeof(CTYPE_LONG_LONG) > { typedef long long type; static const bool value = true; };
                                                             ^
../inst/include/Rcpp/algorithm.h:77:80: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
    struct ctype_helper< sizeof(CTYPE_UNSIGNED_LONG_LONG) > { typedef unsigned long long type; static const bool value = true; };
                                                                               ^
../inst/include/Rcpp/algorithm.h:89:43: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
        static CTYPE_LONG_LONG test(const long long &);
                                          ^
../inst/include/Rcpp/algorithm.h:100:61: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
        static CTYPE_UNSIGNED_LONG_LONG test(const unsigned long long &);
                                                            ^
../inst/include/Rcpp/algorithm.h:117:43: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
        static CTYPE_LONG_LONG test(const long long &);
                                          ^
../inst/include/Rcpp/algorithm.h:128:61: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
        static CTYPE_UNSIGNED_LONG_LONG test(const unsigned long long &);
                                                            ^
6 warnings generated.

Using g++ with the same compiler flags, I do not get these warnings. Replacing long long and unsigned long long with rcpp_long_long_type and rcpp_ulong_long_type, respectively, seems to fix this. I can submit a PR if there are no objections with this approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions