Hi folks,
This issue happens both when editing C++ files inline and building packages with Rcpp:
error: 'Rcpp::NumericVector' (aka 'int') is not a class, namespace, or enumeration
C++ autocomplete and compilation work ok though.
Here are more system details:
RStudio desktop version: 1.3.959
OS version: macOS 10.15.5
Xcode version: 11.5
R Version: 4.0.2
Here is the output by setting .rs.setClangDiagnostics(2)
:
CLANG INDEXING: /Users/nanx/packages/directory-name/dp.cpp
GENERATING PRECOMPILED HEADERS:
[
"-isystem",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"-I/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include",
"-I/usr/local/include",
"-I/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1",
"-I/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include",
"-I/Library/Developer/CommandLineTools/usr/include",
"-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"-I/Library/Frameworks/R.framework/Resources/include",
"-DNDEBUG",
"-I/Users/nanx/rpkgs/Rcpp/include",
"-I/Users/nanx/packages/directory-name",
"-I/usr/local/include",
"-fPIC",
"-I/Users/nanx/rpkgs/Rcpp/include",
"-std=gnu++11"
]
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'signbit' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'fpclassify' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isfinite' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isinf' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnan' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'isnormal' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:324:9: error: no member named 'isgreater' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isgreaterequal' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'isless' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessequal' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'islessgreater' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:330:9: error: no member named 'isunordered' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:336:9: error: no member named 'abs' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:26: error: use of undeclared identifier 'numeric_limits'
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:41: error: '_FloatT' does not refer to a value
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:640:30: note: declared here
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:51: error: no member named 'digits' in the global namespace
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:60: error: use of undeclared identifier 'numeric_limits'
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:75: error: '_IntT' does not refer to a value
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:640:17: note: declared here
fatal error: too many errors emitted, stopping now [-ferror-limit=]
COMPILATION ARGUMENTS:
[
"-isystem",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"-I/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include",
"-I/usr/local/include",
"-I/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1",
"-I/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include",
"-I/Library/Developer/CommandLineTools/usr/include",
"-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"-std=gnu++11",
"-I/Library/Frameworks/R.framework/Resources/include",
"-DNDEBUG",
"-I/Users/nanx/rpkgs/Rcpp/include",
"-I/Users/nanx/packages/directory-name",
"-I/usr/local/include",
"-fPIC",
"-include-pch",
"/var/folders/w4/h1qfny1d0bq5qx4r80pq1xnm0000gn/T/RtmpfZeEJo/rstudio/libclang/precompiled/Rcpp/BF8FD8BE/1.0.4.6-x86_64-apple-darwin17.0-78730-11.0.0/Rcpp-std=gnu++11.pch",
"-v"
]
(Creating new index)
Apple clang version 11.0.0 (clang-1100.0.33.16)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring nonexistent directory "/usr/include"
ignoring duplicate directory "/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/usr/local/include"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include"
as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/Library/Developer/CommandLineTools/usr/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/Library/Frameworks/R.framework/Resources/include
/Users/nanx/rpkgs/Rcpp/include
/Users/nanx/packages/directory-name
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1
/usr/local/include
/Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include
/Library/Developer/CommandLineTools/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
/Users/nanx/packages/directory-name/dp.cpp:7:49: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
/Users/nanx/packages/directory-name/dp.cpp:7:72: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:682:38: error: no type named 'const_pointer' in 'std::__1::allocator_traits<std::__1::allocator<char> >'
/Users/nanx/packages/directory-name/dp.cpp:10:10: note: in instantiation of template class 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >' requested here
/Users/nanx/packages/directory-name/dp.cpp:15:13: error: type 'Rcpp::NumericVector' (aka 'int') does not provide a subscript operator
/Users/nanx/packages/directory-name/dp.cpp:19:12: error: 'Rcpp::NumericVector' (aka 'int') is not a class, namespace, or enumeration
/Users/nanx/packages/directory-name/dp.cpp:19:35: error: subscripted value is not an array, pointer, or vector
/Users/nanx/packages/directory-name/dp.cpp:23:17: error: type 'Rcpp::NumericVector' (aka 'int') does not provide a subscript operator
/Users/nanx/packages/directory-name/dp.cpp:30:19: error: no matching function for call to 'sum'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/sum.h:98:32: note: candidate template ignored: could not match 'VectorBase<13, NA, type-parameter-0-1>' against 'int'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/sum.h:103:33: note: candidate template ignored: could not match 'VectorBase<14, LHS_NA, type-parameter-0-1>' against 'int'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/sum.h:108:32: note: candidate template ignored: could not match 'VectorBase<10, LHS_NA, type-parameter-0-1>' against 'int'
/Users/nanx/packages/directory-name/dp.cpp:30:29: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
/Users/nanx/packages/directory-name/dp.cpp:31:10: error: no matching function for call to 'sum'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/sum.h:98:32: note: candidate template ignored: could not match 'VectorBase<13, NA, type-parameter-0-1>' against 'double'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/sum.h:103:33: note: candidate template ignored: could not match 'VectorBase<14, LHS_NA, type-parameter-0-1>' against 'double'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/sum.h:108:32: note: candidate template ignored: could not match 'VectorBase<10, LHS_NA, type-parameter-0-1>' against 'double'
/Users/nanx/packages/directory-name/dp.cpp:37:12: error: member reference base type 'Rcpp::IntegerVector' (aka 'int') is not a structure or union
/Users/nanx/packages/directory-name/dp.cpp:41:6: error: subscripted value is not an array, pointer, or vector
/Users/nanx/packages/directory-name/dp.cpp:41:13: error: subscripted value is not an array, pointer, or vector
/Users/nanx/packages/directory-name/dp.cpp:43:4: error: subscripted value is not an array, pointer, or vector
/Users/nanx/packages/directory-name/dp.cpp:51:21: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
/Users/nanx/packages/directory-name/dp.cpp:51:39: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
/Users/nanx/packages/directory-name/dp.cpp:52:26: error: no matching function for call to 'match'
/Users/nanx/rpkgs/Rcpp/include/Rcpp/sugar/functions/match.h:28:22: note: candidate template ignored: could not match 'VectorBase<RTYPE, na, type-parameter-0-2>' against 'int'
/Users/nanx/packages/directory-name/dp.cpp:54:12: error: member reference base type 'Rcpp::NumericVector' (aka 'int') is not a structure or union
/Users/nanx/packages/directory-name/dp.cpp:55:17: error: excess elements in scalar initializer
fatal error: too many errors emitted, stopping now [-ferror-limit=]
TOTAL MEMORY: 28 mb (dp.cpp)
PERFORMANCE 2438 ms (dp.cpp)