Using Memory Sanitizer instrumented libc++ - c++

I have built an instrumented libc++ as described here. I have set the flags as the above site suggests:
MSAN_CFLAGS="-fsanitize=memory -stdlib=libc++ -L/path_to/llvm-build-msan/lib -lc++abi -I/path_to/llvm-build-msan/include -I/path_to/llvm-build-msan/include/c++/v1"
and tried to build this:
#include <string.h>
#include <stdio.h>
int main(){
char str[] = "This is a sample string";
char * pch;
printf ("Looking for the 's' character in \"%s\"...\n",str);
pch=strchr(str,'s');
}
with: clang++ ${MSAN_CFLAGS} m.cpp. I got:
In file included from m.cpp:1:
/path_to/llvm-build-msan/include/c++/v1/string.h:74:64: error: use of undeclared identifier 'strchr'
char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:81:75: error: use of undeclared identifier 'strpbrk'
char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:88:65: error: use of undeclared identifier 'strrchr'; did you mean 'strchr'?
char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:76:13: note: 'strchr' declared here
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:95:49: error: unknown type name 'size_t'
void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:97:46: error: unknown type name 'size_t'
const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:99:46: error: unknown type name 'size_t'
void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:102:74: error: use of undeclared identifier 'strstr'; did you mean 'strchr'?
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:78:13: note: 'strchr' declared here
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:102:74: error: no matching function for call to 'strchr'
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:78:13: note: candidate disabled: <no message provided>
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/path_to/llvm-build-msan/include/c++/v1/string.h:102:81: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^~~~
/path_to/llvm-build-msan/include/c++/v1/string.h:78:32: note: passing argument to parameter '__s' here
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
m.cpp:7:5: error: use of undeclared identifier 'printf'
printf ("Looking for the 's' character in \"%s\"...\n",str);
^
10 errors generated.
I also tried to build a memory sanitized clang++ using the same method as to build libc++, but I got:
[ 9%] Building Checkers.inc...
==20994==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x53bf93 in _M_lower_bound /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/stl_tree.h:1887:7
#1 0x53bf93 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::unique_ptr<llvm::Record, std::default_delete<llvm::Record> > >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::unique_ptr<llvm::Record, std::default_delete<llvm::Record> > > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::unique_ptr<llvm::Record, std::default_delete<llvm::Record> > > > >::find(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/stl_tree.h:2536
#2 0x6f0f32 in find /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/stl_map.h:1174:21
#3 0x6f0f32 in getClass /path_to/llvm/include/llvm/TableGen/Record.h:1536
#4 0x6f0f32 in llvm::TGParser::ParseClass() /path_to/llvm/lib/TableGen/TGParser.cpp:2130
#5 0x6f0924 in llvm::TGParser::ParseObject(llvm::MultiClass*) /path_to/llvm/lib/TableGen/TGParser.cpp:2669:29
#6 0x6fc77a in ParseObjectList /path_to/llvm/lib/TableGen/TGParser.cpp:2678:9
#7 0x6fc77a in llvm::TGParser::ParseFile() /path_to/llvm/lib/TableGen/TGParser.cpp:2686
#8 0x688049 in llvm::TableGenMain(char*, bool (*)(llvm::raw_ostream&, llvm::RecordKeeper&)) /path_to/llvm/lib/TableGen/Main.cpp:96:14
#9 0x61b5d5 in main /path_to/llvm/tools/clang/utils/TableGen/TableGen.cpp:287:10
#10 0x7f03af5691c0 in __libc_start_main /build/glibc-CxtIbX/glibc-2.26/csu/../csu/libc-start.c:308
#11 0x424d99 in _start (/path_to/llvm-build/bin/clang-tblgen+0x424d99)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/stl_tree.h:1887:7 in _M_lower_bound
Exiting
tools/clang/include/clang/StaticAnalyzer/Checkers/CMakeFiles/ClangSACheckers.dir/build.make:94: recipe for target 'tools/clang/include/clang/StaticAnalyzer/Checkers/Checkers.inc.tmp' failed
make[3]: *** [tools/clang/include/clang/StaticAnalyzer/Checkers/Checkers.inc.tmp] Error 77
CMakeFiles/Makefile2:18275: recipe for target 'tools/clang/include/clang/StaticAnalyzer/Checkers/CMakeFiles/ClangSACheckers.dir/all' failed
make[2]: *** [tools/clang/include/clang/StaticAnalyzer/Checkers/CMakeFiles/ClangSACheckers.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
Any suggestions how to compile the above code?
Of course, clang++ m.cpp works, but in this case the executable is linked to libstdc++.

Found the solution here:
compile with uninstrumented clang with -fsanitize=memory
link with the above MSAN_CFLAGS (you can omit the include paths), adding -Wl,-rpath -Wl,/path_to/llvm-build-msan/lib/

Related

C++ compilation problem showing problem with header files on macos

tried to run a cpp file and i get the same error no matter which file I run . How to fix this ?
This is the same even if I use g++ (homebrew) .
I thought about deleting usr/include/c++/v1 and then try to re-install it . But not confident if that would be a good idea ,
$ clang++ contrc.cpp
In file included from contrc.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:37:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:214:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:95:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:137:77: error: use of undeclared identifier 'wcschr'
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:144:87: error: use of undeclared identifier 'wcspbrk'
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:151:78: error: use of undeclared identifier 'wcsrchr'; did you mean 'wcschr'?
wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:139:16: note: 'wcschr' declared here
const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:158:86: error: use of undeclared identifier 'wcsstr'; did you mean 'wcschr'?
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:141:16: note: 'wcschr' declared here
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:158:86: error: no matching function for call to 'wcschr'
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:141:16: note: candidate disabled: <no message provided>
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:158:93: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:141:38: note: passing argument to parameter '__s' here
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:165:60: error: unknown type name 'size_t'
wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__s, __c, __n);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:167:57: error: unknown type name 'size_t'
const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/wchar.h:169:57: error: unknown type name 'size_t'
wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, __c, __n);}
^
In file included from contrc.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:37:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:214:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:189:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> streampos;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:190:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> wstreampos;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:192:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> u8streampos;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:195:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> u16streampos;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:196:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> u32streampos;
^
In file included from contrc.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:37:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:215:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:14:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:506:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:639:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/initializer_list:46:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstddef:49:9: error: no member named 'ptrdiff_t' in the global namespace
using ::ptrdiff_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstddef:50:9: error: no member named 'size_t' in the global namespace
using ::size_t;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstddef:53:9: error: no member named 'max_align_t' in the global namespace
using ::max_align_t;
~~^
In file included from contrc.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:37:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:215:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:14:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:506:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:639:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/initializer_list:61:5: error: unknown type name 'size_t'
size_t __size_;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/initializer_list:65:38: error: unknown type name 'size_t'
initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Clang can't compile basic header files (like <iostream>) in macOS

My macOS version is 10.14
Xcode version is 10.2
To write the plugin for clang. I just install the llvm and clang from Github with following commands.
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" ../llvm
Then with clang --version, it shows:
clang version 10.0.0 (https://github.com/llvm/llvm-project.git 73f702ff192475b27039325a7428ce037771a5de)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Users/kim/GitHub/llvm-project/build/bin
Now, I just try to compile very easy Hello World program:
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
with command clang++ test.cpp -o test
But unfortunately, it can't compile with error:
In file included from test.cpp:1:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iostream:37:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/ios:214:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iosfwd:95:
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:136:77: error: use of undeclared
identifier 'wcschr'
wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcschr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:143:87: error: use of undeclared
identifier 'wcspbrk'
wchar_t* __libcpp_wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcspbrk(__s1, __s2);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:150:78: error: use of undeclared
identifier 'wcsrchr'; did you mean 'wcschr'?
wchar_t* __libcpp_wcsrchr(const wchar_t* __s, wchar_t __c) {return (wchar_t*)wcsrchr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:138:16: note: 'wcschr' declared here
const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:157:86: error: use of undeclared
identifier 'wcsstr'; did you mean 'wcschr'?
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:140:16: note: 'wcschr' declared here
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:157:86: error: no matching function for
call to 'wcschr'
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:140:16: note: candidate disabled: <no
message provided>
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:157:93: error: cannot initialize a
parameter of type 'wchar_t *' with an lvalue of type 'const wchar_t *'
wchar_t* __libcpp_wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return (wchar_t*)wcsstr(__s1, __s2);}
^~~~
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:140:38: note: passing argument to
parameter '__s' here
wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return __libcpp_wcschr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:164:60: error: unknown type name
'size_t'
wchar_t* __libcpp_wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return (wchar_t*)wmemchr(__...
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:166:57: error: unknown type name
'size_t'
const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, _...
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:168:57: error: unknown type name
'size_t'
wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, _...
^
In file included from test.cpp:1:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iostream:37:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/ios:214:
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iosfwd:189:14: error: use of undeclared
identifier 'mbstate_t'
typedef fpos<mbstate_t> streampos;
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iosfwd:190:14: error: use of undeclared
identifier 'mbstate_t'
typedef fpos<mbstate_t> wstreampos;
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iosfwd:195:14: error: use of undeclared
identifier 'mbstate_t'
typedef fpos<mbstate_t> u16streampos;
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iosfwd:196:14: error: use of undeclared
identifier 'mbstate_t'
typedef fpos<mbstate_t> u32streampos;
^
In file included from test.cpp:1:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iostream:37:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/ios:215:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/__locale:14:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string:504:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string_view:175:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/__string:56:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/algorithm:641:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/cstring:60:
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:73:64: error: use of undeclared
identifier 'strchr'
char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:80:75: error: use of undeclared
identifier 'strpbrk'
char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:87:65: error: use of undeclared
identifier 'strrchr'; did you mean 'strchr'?
char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:75:13: note: 'strchr' declared here
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:94:76: error: use of undeclared
identifier 'memchr'; did you mean 'wmemchr'?
void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/wchar.h:166:16: note: 'wmemchr' declared here
const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return __libcpp_wmemchr(__s, _...
^
In file included from test.cpp:1:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/iostream:37:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/ios:215:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/__locale:14:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string:504:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string_view:175:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/__string:56:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/algorithm:641:
In file included from /Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/cstring:60:
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:101:74: error: use of undeclared
identifier 'strstr'; did you mean 'strchr'?
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:77:13: note: 'strchr' declared here
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:101:74: error: no matching function for
call to 'strchr'
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
^
/Users/kim/GitHub/llvm-project/build/bin/../include/c++/v1/string.h:77:13: note: candidate disabled: <no
message provided>
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
I have tried adding -std=c++11, -stdlib=libc++, but there are same errors.
I was getting this error while attempting to build and debug C++ code in VSCode.
For me the answer was found here:
https://github.com/rstudio/rstudio/issues/7824#issuecomment-694481241
TLDR;
xcode was configured to use the developer tools
▶ xcode-select -p
/Applications/Xcode.app/Contents/Developer
Switching to the command line tools resolved the problem.
sudo xcode-select -s /Library/Developer/CommandLineTools
It can be compiled through
clang++ -std=c++11 -stdlib=libc++ -nostdinc++ -I/.../llvm-project/libcxx/include -L/.../llvm-project/libcxx/lib -Wl,-rpath,/.../llvm-project/libcxx/lib test.cpp -o test

Print private/public key

For testing purposes, I want to print my public and private key which are generated on the Arduino via elliptic curve.
The relevant code looks as follows,
#include <Ed25519.h>
void setup()
{
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
uint8_t privateKey[32];
uint8_t publicKey[32];
Ed25519::generatePrivateKey(privateKey);
Ed25519::derivePublicKey(publicKey, privateKey);
Serial.println(publicKey);
Serial.print(",");
Serial.write(privateKey);
}
However, it gives me the following error:
/tmp/arduino_modified_sketch_961866/ask_receiver.pde: In function 'void setup()':
ask_receiver:52: error: call of overloaded 'println(uint8_t [32])' is ambiguous
Serial.println(publicKey);
^
/tmp/arduino_modified_sketch_961866/ask_receiver.pde:5
2:29: note: candidates are:
In file included from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Stream.h:26:0,
from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:29,
from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Arduino.h:232,
from sketch/ask_receiver.pde.cpp:1:
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:78:12: note: size_t Print::println(const String&) <near match>
size_t println(const String &s);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:78:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'const String&'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:79:12: note: size_t Print::println(const char*) <near match>
size_t println(const char[]);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:79:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'const char*'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:80:12: note: size_t Print::println(char) <near match>
size_t println(char);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:80:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'char'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:81:12: note: size_t Print::println(unsigned char, int) <near match>
size_t println(unsigned char, int = DEC);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:81:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'unsigned char'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:82:12: note: size_t Print::println(int, int) <near match>
size_t println(int, int = DEC);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:82:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'int'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:83:12: note: size_t Print::println(unsigned int, int) <near match>
size_t println(unsigned int, int = DEC);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:83:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'unsigned int'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:84:12: note: size_t Print::println(long int, int) <near match>
size_t println(long, int = DEC);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:84:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'long int'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:85:12: note: size_t Print::println(long unsigned int, int) <near match>
size_t println(unsigned long, int = DEC);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:85:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'long unsigned int'
ask_receiver:54: error: call of overloaded 'write(uint8_t [32])' is ambiguous
Serial.write(privateKey);
^
/tmp/arduino_modified_sketch_961866/ask_receiver.pde:54:28: note: candidates are:
In file included from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Arduino.h:232:0,
from sketch/ask_receiver.pde.cpp:1:
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:129:20: note: virtual size_t HardwareSerial::write(uint8_t) <near match>
virtual size_t write(uint8_t);
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:129:20: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'uint8_t {aka unsigned char}'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:130:19: note: size_t HardwareSerial::write(long unsigned int) <near match>
inline size_t write(unsigned long n) { return write((uint8_t)n); }
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:130:19: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'long unsigned int'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:131:19: note: size_t HardwareSerial::write(long int) <near match>
inline size_t write(long n) { return write((uint8_t)n); }
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:131:19: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'long int'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:132:19: note: size_t HardwareSerial::write(unsigned int) <near match>
inline size_t write(unsigned int n) { return write((uint8_t)n); }
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:132:19: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'unsigned int'
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:133:19: note: size_t HardwareSerial::write(int) <near match>
inline size_t write(int n) { return write((uint8_t)n); }
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:133:19: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'int'
In file included from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Stream.h:26:0,
from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/HardwareSerial.h:29,
from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Arduino.h:232,
from sketch/ask_receiver.pde.cpp:1:
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:52:12: note: size_t Print::write(const char*) <near match>
size_t write(const char *str) {
^
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Print.h:52:12: note: no known conversion for argument 1 from 'uint8_t [32] {aka unsigned char [32]}' to 'const char*'
/tmp/arduino_modified_sketch_961866/ask_receiver.pde: In function 'void loop()':
/tmp/arduino_modified_sketch_961866/ask_receiver.pde:80:51: warning: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'const char*' [-fpermissive]
driver.printBuffer("Decrypted:", buf, strlen(buf));
^
In file included from /ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/arduino/avr/cores/arduino/Arduino.h:25:0,
from sketch/ask_receiver.pde.cpp:1:
/ogobase/home/henk/Downloads/arduino-1.8.5-linux64/arduino-1.8.5/hardware/tools/avr/avr/include/string.h:399:15: note: initializing argument 1 of 'size_t strlen(const char*)'
extern size_t strlen(const char *) __ATTR_PURE__;
^
exit status 1
call of overloaded 'println(uint8_t [32])' is ambiguous
I have also tried:
Serial.write((int)privateKey);
But it gives me gibberish output.
I also tried:
String stringOne = String(privateKey, HEX)
Serial.println(stringOne);
But it gives me the following output:
call of overloaded 'String(uint8_t [32], int)' is ambiguous
Preferably, I'd output it in HEX or some other value which I can transfer over another medium.
Solved it by using a simple for loop
uint8_t i;
for (i = 0; i < (uint8_t)(sizeof(privateKey)); i++) {
if (privateKey[i] < 0x10) { /* To print "0F", not "F" */
Serial.write('0');
}
Serial.print(privateKey[i], HEX);
}

How to cast a char* to a byte* in c++?

I am very new in c++ and want to cast a char* from a std::string to a byte*.
Here is my code:
inline string XOR(const string &value, const string &key) {
string retval(value);
CryptoPP::xorbuf(&retval[0], &key[0], retval.length());
return retval;
}
In g++, the output is:
AESXCBC128.cpp: In function ‘std::string CryptoPP::XOR(const string&, const string&)’:
AESXCBC128.cpp:79:48: error: invalid conversion from ‘char*’ to ‘byte* {aka unsigned char*}’ [-fpermissive]
xorbuf(&retval[0], &key[0], retval.length());
^
AESXCBC128.cpp:45:6: error: initializing argument 1 of ‘void CryptoPP::xorbuf(byte*, const byte*, size_t)’ [-fpermissive]
void xorbuf(byte *buf, const byte *mask, size_t count)
^
AESXCBC128.cpp:79:48: error: invalid conversion from ‘const char*’ to ‘const byte* {aka const unsigned char*}’ [-fpermissive]
xorbuf(&retval[0], &key[0], retval.length());
^
AESXCBC128.cpp:45:6: error: initializing argument 2 of ‘void CryptoPP::xorbuf(byte*, const byte*, size_t)’ [-fpermissive]
void xorbuf(byte *buf, const byte *mask, size_t count)
inline string XOR(const string &value, const string &key) {
string retval(value);
CryptoPP::xorbuf(&retval[0], &key[0], retval.length());
return retval;
}
Crypto++ typedefs a byte in confg.h:
typedef unsigned char byte;
You can use something like:
CryptoPP::xorbuf(
reinterpret_cast<byte*>(&retval[0]),
reinterpret_cast<const byte*>(&key[0]),
retval.length());
Or, you can do it with C-style casts:
CryptoPP::xorbuf((byte*)&retval[0], (const byte*)&key[0], retval.length());
Here are some similar questions for SecByteBlock, which is a byte array rather than a char array:
How to convert SecByteBlock to string?
string to SecByteBlock conversion
Here are some references on C++ casting:
When should static_cast, dynamic_cast, const_cast and reinterpret_cast be used?
Regular cast vs. static_cast vs. dynamic_cast

boost error: reference to 'detail' is ambiguous

I'm compiling a large program with gcc-4.4.7 --std=c++0x and several libraries from boost-1.53. The compiler is complaining about a bunch of errors in the boost libraries (below), but not about my code. Is this a bug in boost libraries? How would I go about figuring out what's wrong? Any suggestions appreciated!
/usr/bin/g++ -O0 -ggdb -fno-inline --std=c++0x -pedantic -Wall -fno-strict-aliasing -Wno-non-template-friend -Wno-long-long -Wno-deprecated -m64 -I /home/user1/pkg/boost-64bit -I/data/home_local/user2/dev/bbb-onForge-trunk/src -I/data/home_local/user2/dev/bbb-onForge-trunk/src/util/containers -I/data/home_local/user2/dev/bbb-onForge-trunk/src/util/misc -I /usr/include -c -o /data/home_local/user2/dev/bbb-onForge-trunk/obj/Linux/dbg/bbb/trainOne.o /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp
In file included from /home/user1/pkg/boost-64bit/boost/filesystem/path_traits.hpp:23,
from /home/user1/pkg/boost-64bit/boost/filesystem/path.hpp:25,
from /home/user1/pkg/boost-64bit/boost/filesystem.hpp:16,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/parameter.hpp:31,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp:6:
/home/user1/pkg/boost-64bit/boost/system/error_code.hpp: In function 'boost::system::error_code& boost::throws()':
/home/user1/pkg/boost-64bit/boost/system/error_code.hpp:410: error: reference to 'detail' is ambiguous
/home/user1/pkg/boost-64bit/boost/type_traits/is_reference.hpp:25: error: candidates are: namespace boost::detail { }
/home/user1/pkg/boost-64bit/boost/tuple/detail/tuple_basic.hpp:51: error: namespace boost::tuples::detail { }
In file included from /home/user1/pkg/boost-64bit/boost/tokenizer.hpp:20,
from /home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:15,
from /home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:13,
from /home/user1/pkg/boost-64bit/boost/date_time/gregorian/gregorian.hpp:34,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/time_formatters.hpp:12,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/posix_time.hpp:24,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/util/misc/ResourceUsage.hpp:4,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp:6:
/home/user1/pkg/boost-64bit/boost/token_iterator.hpp: At global scope:
/home/user1/pkg/boost-64bit/boost/token_iterator.hpp:34: error: reference to 'detail' is ambiguous
/home/user1/pkg/boost-64bit/boost/type_traits/is_reference.hpp:25: error: candidates are: namespace boost::detail { }
/home/user1/pkg/boost-64bit/boost/tuple/detail/tuple_basic.hpp:51: error: namespace boost::tuples::detail { }
/home/user1/pkg/boost-64bit/boost/token_iterator.hpp:39: error: template argument 3 is invalid
In file included from /home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:13,
from /home/user1/pkg/boost-64bit/boost/date_time/gregorian/gregorian.hpp:34,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/time_formatters.hpp:12,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/posix_time.hpp:24,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/util/misc/ResourceUsage.hpp:4,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp:6:
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp: In function 'date_type boost::date_time::parse_date(const std::string&, int)':
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:133: error: no match for 'operator!=' in 'beg != tok.boost::tokenizer<TokenizerFunc, Iterator, Type>::end [with TokenizerFunc = boost::char_separator<char, std::char_traits<char> >, Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Type = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]()'
/home/user1/pkg/boost-64bit/boost/tuple/tuple_comparison.hpp:41: note: candidates are: bool boost::tuples::operator!=(const boost::tuples::null_type&, const boost::tuples::null_type&)
/home/user1/pkg/boost-64bit/boost/blank.hpp:73: note: bool boost::operator!=(const boost::blank&, const boost::blank&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:764: note: bool boost::operator!=(boost::detail::function::useless_clear_type*, const boost::function_base&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:752: note: bool boost::operator!=(const boost::function_base&, boost::detail::function::useless_clear_type*)
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:134: error: no match for 'operator++' in '++beg'
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:138: error: no match for 'operator*' in '*beg'
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:143: error: no match for 'operator*' in '*beg'
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:148: error: no match for 'operator*' in '*beg'
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp: In function 'date_type boost::date_time::parse_undelimited_date(const std::string&)':
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:178: error: no match for 'operator!=' in 'ti != tok.boost::tokenizer<TokenizerFunc, Iterator, Type>::end [with TokenizerFunc = boost::offset_separator, Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Type = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]()'
/home/user1/pkg/boost-64bit/boost/tuple/tuple_comparison.hpp:41: note: candidates are: bool boost::tuples::operator!=(const boost::tuples::null_type&, const boost::tuples::null_type&)
/home/user1/pkg/boost-64bit/boost/blank.hpp:73: note: bool boost::operator!=(const boost::blank&, const boost::blank&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:764: note: bool boost::operator!=(boost::detail::function::useless_clear_type*, const boost::function_base&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:752: note: bool boost::operator!=(const boost::function_base&, boost::detail::function::useless_clear_type*)
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:178: error: no match for 'operator++' in '++ti'
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:179: error: no match for 'operator*' in '*ti'
In file included from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/time_formatters.hpp:19,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/posix_time.hpp:24,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/util/misc/ResourceUsage.hpp:4,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp:6:
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp: In function 'time_duration boost::date_time::parse_undelimited_time_duration(const std::string&)':
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:228: error: no match for 'operator!=' in 'ti != tok.boost::tokenizer<TokenizerFunc, Iterator, Type>::end [with TokenizerFunc = boost::offset_separator, Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Type = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]()'
/home/user1/pkg/boost-64bit/boost/tuple/tuple_comparison.hpp:41: note: candidates are: bool boost::tuples::operator!=(const boost::tuples::null_type&, const boost::tuples::null_type&)
/home/user1/pkg/boost-64bit/boost/blank.hpp:73: note: bool boost::operator!=(const boost::blank&, const boost::blank&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:764: note: bool boost::operator!=(boost::detail::function::useless_clear_type*, const boost::function_base&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:752: note: bool boost::operator!=(const boost::function_base&, boost::detail::function::useless_clear_type*)
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:228: error: no match for 'operator++' in '++ti'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:232: error: no match for 'operator*' in '*ti'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:237: error: no match for 'operator*' in '*ti'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:242: error: no match for 'operator*' in '*ti'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:247: error: base operand of '->' has non-pointer type 'boost::date_time::parse_undelimited_time_duration(const std::string&)::tokenizer_iterator'
In file included from /home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:13,
from /home/user1/pkg/boost-64bit/boost/date_time/gregorian/gregorian.hpp:34,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/time_formatters.hpp:12,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/posix_time.hpp:24,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/util/misc/ResourceUsage.hpp:4,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp:6:
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp: In function 'boost::date_time::period<date_type, typename date_type::duration_type> boost::date_time::from_simple_string_type(const std::basic_string<charT, std::char_traits<_CharT>, std::allocator<_T2> >&) [with date_type = boost::gregorian::date, charT = char]':
/home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:79: instantiated from here
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:299: error: no match for 'operator*' in '*tok_it'
/home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:79: instantiated from here
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:305: error: no match for 'operator++' in '++tok_it'
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp: In function 'boost::date_time::period<date_type, typename date_type::duration_type> boost::date_time::from_simple_string_type(const std::basic_string<charT, std::char_traits<_CharT>, std::allocator<_T2> >&) [with date_type = boost::gregorian::date, charT = wchar_t]':
/home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:84: instantiated from here
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:299: error: no match for 'operator*' in '*tok_it'
/home/user1/pkg/boost-64bit/boost/date_time/gregorian/parsers.hpp:84: instantiated from here
/home/user1/pkg/boost-64bit/boost/date_time/date_parsing.hpp:305: error: no match for 'operator++' in '++tok_it'
In file included from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/time_formatters.hpp:19,
from /home/user1/pkg/boost-64bit/boost/date_time/posix_time/posix_time.hpp:24,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/util/misc/ResourceUsage.hpp:4,
from /data/home_local/user2/dev/bbb-onForge-trunk/src/bbb/trainOne.cpp:6:
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp: In function 'time_duration boost::date_time::str_from_delimited_time_duration(const std::basic_string<charT, std::char_traits<_CharT>, std::allocator<_T2> >&) [with time_duration = boost::posix_time::time_duration, char_type = char]':
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:146: instantiated from 'time_duration boost::date_time::parse_delimited_time_duration(const std::string&) [with time_duration = boost::posix_time::time_duration]'
/home/user1/pkg/boost-64bit/boost/date_time/posix_time/time_parsers.hpp:27: instantiated from here
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:68: error: no match for 'operator!=' in 'beg != boost::tokenizer<TokenizerFunc, Iterator, Type>::end() const [with TokenizerFunc = boost::char_separator<char, std::char_traits<char> >, Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Type = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]()'
/home/user1/pkg/boost-64bit/boost/tuple/tuple_comparison.hpp:41: note: candidates are: bool boost::tuples::operator!=(const boost::tuples::null_type&, const boost::tuples::null_type&)
/home/user1/pkg/boost-64bit/boost/blank.hpp:73: note: bool boost::operator!=(const boost::blank&, const boost::blank&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:764: note: bool boost::operator!=(boost::detail::function::useless_clear_type*, const boost::function_base&)
/home/user1/pkg/boost-64bit/boost/function/function_base.hpp:752: note: bool boost::operator!=(const boost::function_base&, boost::detail::function::useless_clear_type*)
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:68: error: no match for 'operator++' in '++beg'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:71: error: no match for 'operator*' in '*beg'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:75: error: no match for 'operator*' in '*beg'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:79: error: no match for 'operator*' in '*beg'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:83: error: base operand of '->' has non-pointer type 'boost::date_time::str_from_delimited_time_duration(const std::basic_string<charT, std::char_traits<_CharT>, std::allocator<_T2> >&) [with time_duration = boost::posix_time::time_duration, char_type = char]::tokenizer_iterator'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:104: error: base operand of '->' has non-pointer type 'boost::date_time::str_from_delimited_time_duration(const std::basic_string<charT, std::char_traits<_CharT>, std::allocator<_T2> >&) [with time_duration = boost::posix_time::time_duration, char_type = char]::tokenizer_iterator'
/home/user1/pkg/boost-64bit/boost/date_time/time_parsing.hpp:107: error: no match for 'operator*' in '*beg'
Are you doing the below in your code ?
using namespace boost;
using namespace boost::tuples;
If so, Compiler is not able to judge which detail to use from the below files.
/home/user1/pkg/boost-64bit/boost/type_traits/is_reference.hpp
/home/user1/pkg/boost-64bit/boost/tuple/detail/tuple_basic.hpp