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

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.

Related

Open CV installation issues. Mingw problems c++ error

after using cmake on my opencv build folder, I used cmd to run mingw32-make and got the following error.
In file included from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:14,
from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:6:
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp:18:5: error: 'LogLevel' does not name a type
LogLevel level;
^~~~~~~~
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp:20:38: error: 'LogLevel' has not been declared
inline LogTag(const char* _name, LogLevel _level)
^~~~~~~~
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp: In constructor 'cv::utils::logging::LogTag::LogTag(const char*, int)':
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp:22:11: error: class 'cv::utils::logging::LogTag' does not have any field named 'level'
, level(_level)
^~~~~
In file included from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:15,
from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:6:
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:20:5: error: 'LogLevel' does not name a type
LogLevel level;
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:34:48: error: 'LogLevel' has not been declared
LogTagConfig(const std::string& _namePart, LogLevel _level, bool _isGlobal = false,
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp: In constructor 'cv::utils::logging::LogTagConfig::LogTagConfig()':
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:27:11: error: class 'cv::utils::logging::LogTagConfig' does not have any field named 'level'
, level()
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp: In constructor 'cv::utils::logging::LogTagConfig::LogTagConfig(const string&, int, bool, bool, bool)':
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:37:11: error: class 'cv::utils::logging::LogTagConfig' does not have any field named 'level'
, level(_level)
^~~~~
In file included from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:6:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:24:32: error: expected ')' before 'defaultUnconfiguredGlobalLevel'
LogTagConfigParser(LogLevel defaultUnconfiguredGlobalLevel = LOG_LEVEL_VERBOSE);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:40:49: error: 'LogLevel' has not been declared
void parseWildcard(const std::string& name, LogLevel level);
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:41:22: error: 'LogLevel' was not declared in this scope
static std::pair<LogLevel, bool> parseLogLevel(const std::string& s);
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:41:36: error: template argument 1 is invalid
static std::pair<LogLevel, bool> parseLogLevel(const std::string& s);
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:42:33: error: 'LogLevel' has not been declared
static std::string toString(LogLevel level);
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:12:39: error: expected constructor, destructor, or type conversion before '(' token
LogTagConfigParser::LogTagConfigParser(LogLevel defaultUnconfiguredGlobalLevel)
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In member function 'void cv::utils::logging::LogTagConfigParser::parseNameAndLevel(const string&)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:105:25: error: request for member 'second' in 'parsedLevel', which is of non-class type 'int'
if (parsedLevel.second)
^~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:108:43: error: request for member 'first' in 'parsedLevel', which is of non-class type 'int'
parseWildcard("", parsedLevel.first);
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:132:21: error: request for member 'second' in 'parsedLevel', which is of non-class type 'int'
if (parsedLevel.second)
^~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:134:59: error: request for member 'first' in 'parsedLevel', which is of non-class type 'int'
parseWildcard(s.substr(0u, colonIdx), parsedLevel.first);
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:146:65: error: 'LogLevel' has not been declared
void LogTagConfigParser::parseWildcard(const std::string& name, LogLevel level)
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In member function 'void cv::utils::logging::LogTagConfigParser::parseWildcard(const string&, int)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:152:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:158:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:164:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:175:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:193:11: error: 'LogLevel' was not declared in this scope
std::pair<LogLevel, bool> LogTagConfigParser::parseLogLevel(const std::string& s)
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:193:25: error: template argument 1 is invalid
std::pair<LogLevel, bool> LogTagConfigParser::parseLogLevel(const std::string& s)
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In static member function 'static int cv::utils::logging::LogTagConfigParser::parseLogLevel(const string&)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:195:47: error: 'LOG_LEVEL_VERBOSE' was not declared in this scope
const auto falseDontCare = std::make_pair(LOG_LEVEL_VERBOSE, false);
^~~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:195:47: note: suggested alternative: 'CV_LOG_LEVEL_VERBOSE'
const auto falseDontCare = std::make_pair(LOG_LEVEL_VERBOSE, false);
^~~~~~~~~~~~~~~~~
CV_LOG_LEVEL_VERBOSE
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:40: error: 'LogLevel' has not been declared
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:67: error: 'LogLevel' was not declared in this scope
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:67: note: suggested alternative: 'parseLogLevel'
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^~~~~~~~
parseLogLevel
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:81: error: template argument 1 is invalid
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In lambda function:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:198:40: error: cannot convert 'std::pair<int, bool>' to 'int' in return
return std::make_pair(lev, true);
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In static member function 'static int cv::utils::logging::LogTagConfigParser::parseLogLevel(const string&)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:209:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:209:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:216:43: error: 'LOG_LEVEL_DEBUG' was not declared in this scope
return make_parsed_result(LOG_LEVEL_DEBUG);
^~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:216:43: note: suggested alternative: 'CV_LOG_LEVEL_DEBUG'
return make_parsed_result(LOG_LEVEL_DEBUG);
^~~~~~~~~~~~~~~
CV_LOG_LEVEL_DEBUG
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:221:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:221:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:228:43: error: 'LOG_LEVEL_ERROR' was not declared in this scope
return make_parsed_result(LOG_LEVEL_ERROR);
^~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:228:43: note: suggested alternative: 'CV_LOG_LEVEL_ERROR'
return make_parsed_result(LOG_LEVEL_ERROR);
^~~~~~~~~~~~~~~
CV_LOG_LEVEL_ERROR
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:235:43: error: 'LOG_LEVEL_FATAL' was not declared in this scope
return make_parsed_result(LOG_LEVEL_FATAL);
^~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:235:43: note: suggested alternative: 'CV_LOG_LEVEL_FATAL'
return make_parsed_result(LOG_LEVEL_FATAL);
^~~~~~~~~~~~~~~
CV_LOG_LEVEL_FATAL
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:242:43: error: 'LOG_LEVEL_INFO' was not declared in this scope
return make_parsed_result(LOG_LEVEL_INFO);
^~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:242:43: note: suggested alternative: 'CV_LOG_LEVEL_INFO'
return make_parsed_result(LOG_LEVEL_INFO);
^~~~~~~~~~~~~~
CV_LOG_LEVEL_INFO
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:248:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:248:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:255:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:255:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:271:43: error: 'LOG_LEVEL_WARNING' was not declared in this scope
return make_parsed_result(LOG_LEVEL_WARNING);
^~~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:271:43: note: suggested alternative: 'CV_LOG_LEVEL_WARN'
return make_parsed_result(LOG_LEVEL_WARNING);
^~~~~~~~~~~~~~~~~
CV_LOG_LEVEL_WARN
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:282:42: error: 'std::__cxx11::string cv::utils::logging::LogTagConfigParser::toString' is not a static data member of 'class cv::utils::logging::LogTagConfigParser'
std::string LogTagConfigParser::toString(LogLevel level)
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:282:42: error: 'LogLevel' was not declared in this scope
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:282:42: note: suggested alternative: 'parseLogLevel'
std::string LogTagConfigParser::toString(LogLevel level)
^~~~~~~~
parseLogLevel
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:283:1: error: expected ',' or ';' before '{' token
{
^
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1258: modules/core/CMakeFiles/opencv_core.dir/src/utils/logtagconfigparser.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2318: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:182: all] Error 2
Please how do i solve this, and what is LogLevel?.
At first i was using Mingw then i ran into a "mutex" issue.So i changed to Mingw64 to solve it, the I arrived at this problem. Is there a library I'm missing cause I havent found what LogLevel is.

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

Using Memory Sanitizer instrumented libc++

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/

MariaDB C++ Connector compile

I'm trying to compile a simple c++ file that is suppose to use the mariadbc++ connector. For some reason I ran into alot of trouble with that. I get strange error messages. I neither understand them, nor do I know how to fix them.
I did a lot of research, but either nobody else ran into these problems or I just cant find them.
I installed following packages:
mariadb-client
mariadb-client-5.5
mariadb-server
libmariadbclient18
libmysqlclient18
libmysqlcppconn7
libmysqlcppconn-dev
libmariadbclient-dev
libmariadb-dev
I'm on a x64 Ubuntu 14.04 System (well Pinguy OS, but I guess, that doesn't matter)
I tried to build following programm:
#include <my_global.h>
#include <mysql.h>
#include "mysql_driver.h"
int main(int argc, char **argv)
{
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
driver = sql::mysql::MySQL_Driver::get_mysql_driver_instance();
con = driver->connect("tcp://localhost:3306","root", "herein");
if (!con->isValid()) exit(1);
stmt = con->createStatement();
stmt->execute("use testtb");
stmt->execute("INSERT INTO Testtable(id, label) VALUES (1, 1)");
delete stmt;
delete con;
return 1;
}
And I tried this command:
g++ -lmysqlcppconn -g src/test_mariadb.cpp -o bin/test_mariadb $(mysql_config --cflags) $(mysql_config --libs)
where under in src/ my source files are and in bin/ my binaries.
And finally the Compile Errors I get:
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from /usr/include/boost/assert.hpp:82,
from /usr/include/boost/smart_ptr/scoped_ptr.hpp:15,
from /usr/include/boost/scoped_ptr.hpp:14,
from /usr/include/mysql_driver.h:30,
from src/test_mariadb.cpp:3:
/usr/include/c++/4.8/bits/stl_algobase.h:239:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/usr/include/c++/4.8/bits/stl_algobase.h:260:56: error: macro "max" passed 3 arguments, but takes just 2
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
In file included from /usr/include/boost/mpl/aux_/begin_end_impl.hpp:21:0,
from /usr/include/boost/mpl/begin_end.hpp:18,
from /usr/include/boost/mpl/iter_fold.hpp:18,
from /usr/include/boost/variant/detail/initializer.hpp:28,
from /usr/include/boost/variant/variant.hpp:31,
from /usr/include/boost/variant.hpp:17,
from /usr/include/cppconn/connection.h:31,
from /usr/include/cppconn/driver.h:30,
from /usr/include/mysql_driver.h:32,
from src/test_mariadb.cpp:3:
/usr/include/boost/mpl/aux_/has_begin.hpp:20:57: error: macro "test" passed 2 arguments, but takes just 1
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_begin, begin, true)
^
In file included from /usr/include/boost/mpl/sequence_tag.hpp:18:0,
from /usr/include/boost/mpl/begin_end.hpp:19,
from /usr/include/boost/mpl/iter_fold.hpp:18,
from /usr/include/boost/variant/detail/initializer.hpp:28,
from /usr/include/boost/variant/variant.hpp:31,
from /usr/include/boost/variant.hpp:17,
from /usr/include/cppconn/connection.h:31,
from /usr/include/cppconn/driver.h:30,
from /usr/include/mysql_driver.h:32,
from src/test_mariadb.cpp:3:
/usr/include/boost/mpl/aux_/has_tag.hpp:20:54: error: macro "test" passed 2 arguments, but takes just 1
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_tag, tag, false)
^
In file included from /usr/include/boost/mpl/aux_/O1_size_impl.hpp:20:0,
from /usr/include/boost/mpl/O1_size.hpp:19,
from /usr/include/boost/mpl/iter_fold.hpp:19,
from /usr/include/boost/variant/detail/initializer.hpp:28,
from /usr/include/boost/variant/variant.hpp:31,
from /usr/include/boost/variant.hpp:17,
from /usr/include/cppconn/connection.h:31,
from /usr/include/cppconn/driver.h:30,
from /usr/include/mysql_driver.h:32,
from src/test_mariadb.cpp:3:
/usr/include/boost/mpl/aux_/has_size.hpp:20:1: error: macro "test" passed 2 arguments, but takes just 1
BOOST_MPL_HAS_XXX_TRAIT_DEF(size)
^
In file included from /usr/include/boost/mpl/apply_wrap.hpp:23:0,
from /usr/include/boost/mpl/bind.hpp:27,
from /usr/include/boost/mpl/lambda.hpp:18,
from /usr/include/boost/mpl/iter_fold.hpp:20,
from /usr/include/boost/variant/detail/initializer.hpp:28,
from /usr/include/boost/variant/variant.hpp:31,
from /usr/include/boost/variant.hpp:17,
from /usr/include/cppconn/connection.h:31,
from /usr/include/cppconn/driver.h:30,
from /usr/include/mysql_driver.h:32,
from src/test_mariadb.cpp:3:
/usr/include/boost/mpl/aux_/has_apply.hpp:22:58: error: macro "test" passed 2 arguments, but takes just 1
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_apply, apply, false)
^
In file included from /usr/include/boost/mpl/quote.hpp:23:0,
from /usr/include/boost/mpl/aux_/full_lambda.hpp:25,
from /usr/include/boost/mpl/lambda.hpp:22,
from /usr/include/boost/mpl/iter_fold.hpp:20,
from /usr/include/boost/variant/detail/initializer.hpp:28,
from /usr/include/boost/variant/variant.hpp:31,
from /usr/include/boost/variant.hpp:17,
from /usr/include/cppconn/connection.h:31,
from /usr/include/cppconn/driver.h:30,
from /usr/include/mysql_driver.h:32,
from src/test_mariadb.cpp:3:
/usr/include/boost/mpl/aux_/has_type.hpp:20:55: error: macro "test" passed 2 arguments, but takes just 1
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_type, type, true)
^
In file included from src/test_mariadb.cpp:1:0:
/usr/include/c++/4.8/bits/stl_algobase.h:193:5: error: expected unqualified-id before ‘const’
min(const _Tp& __a, const _Tp& __b)
^
/usr/include/c++/4.8/bits/stl_algobase.h:193:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8/bits/stl_algobase.h:193:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8/bits/stl_algobase.h:193:5: error: expected initializer before ‘const’
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: error: expected unqualified-id before ‘const’
max(const _Tp& __a, const _Tp& __b)
^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: error: expected initializer before ‘const’
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from /usr/include/boost/assert.hpp:82,
from /usr/include/boost/smart_ptr/scoped_ptr.hpp:15,
from /usr/include/boost/scoped_ptr.hpp:14,
from /usr/include/mysql_driver.h:30,
from src/test_mariadb.cpp:3:
/usr/include/c++/4.8/bits/stl_algobase.h:239:5: error: ‘std::min’ declared as an ‘inline’ variable
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/usr/include/c++/4.8/bits/stl_algobase.h:239:5: error: template declaration of ‘const _Tp& std::min’
/usr/include/c++/4.8/bits/stl_algobase.h:242:7: error: expected primary-expression before ‘if’
if (__comp(__b, __a))
^
/usr/include/c++/4.8/bits/stl_algobase.h:242:7: error: expected ‘}’ before ‘if’
/usr/include/c++/4.8/bits/stl_algobase.h:244:7: error: expected unqualified-id before ‘return’
return __a;
^
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: error: ‘max’ declared as an ‘inline’ variable
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: error: template declaration of ‘const _Tp& max’
/usr/include/c++/4.8/bits/stl_algobase.h:263:7: error: expected primary-expression before ‘if’
if (__comp(__a, __b))
^
/usr/include/c++/4.8/bits/stl_algobase.h:263:7: error: expected ‘}’ before ‘if’
/usr/include/c++/4.8/bits/stl_algobase.h:265:7: error: expected unqualified-id before ‘return’
return __a;
^
/usr/include/c++/4.8/bits/stl_algobase.h:266:5: error: expected declaration before ‘}’ token
}
A header you have included has defined preprocessor macros named min, max and test. These have then conflicted with identifiers used (e.g. for method names) in other header files you have included.
Assuming that those macros have been defined in one of these headers:
#include <my_global.h>
#include <mysql.h>
you could add #undefs before you include mysql_driver.h, e.g.:
#include <my_global.h>
#include <mysql.h>
#undef min
#undef max
#undef test
#include "mysql_driver.h"
You could also consider re-arranging the order in which you include the files, or look into what headers are defining these and see whether the definition of these macros can be disabled.

Suspected std::array C++11 library is broken? What do I do?

From google I can't seem to find clear answers, But I don't know what to do. I suspected there might be a problem in a larger program I was writing with the array C++11 library for g++ and wrote a test program. I am using g++ 4.8.1.
main.cpp:
#include <iostream>
#include <array>
int main()
{
std::array<int,5> vector;
return 0;
}
My test command line compile is:
g++ main.cpp -std=c++11
with errors..
In file included from main.cpp:2:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:107:12: error: 'array' has not been declared
swap(array& __other)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: In member function 'void std::Array<_Tp, _Nm>::swap(int&)':
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:109:50: error: request for member 'begin' in '__other', which is of non-class type 'int'
{ std::swap_ranges(begin(), end(), __other.begin()); }
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: At global scope:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:228:22: error: 'array' does not name a type
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:228:27: error: expected ',' or '...' before '<' token
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:228:74: error: 'bool std::operator==(int)' must have an argument of class or enumerated type
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:233:22: error: 'array' does not name a type
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:233:27: error: expected ',' or '...' before '<' token
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:233:74: error: 'bool std::operator!=(int)' must have an argument of class or enumerated type
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:238:21: error: 'array' does not name a type
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:238:26: error: expected ',' or '...' before '<' token
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:238:69: error: 'bool std::operator<(int)' must have an argument of class or enumerated type
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:246:21: error: 'array' does not name a type
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:246:26: error: expected ',' or '...' before '<' token
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:246:73: error: 'bool std::operator>(int)' must have an argument of class or enumerated type
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:251:22: error: 'array' does not name a type
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:251:27: error: expected ',' or '...' before '<' token
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:251:74: error: 'bool std::operator<=(int)' must have an argument of class or enumerated type
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:256:22: error: 'array' does not name a type
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:256:27: error: expected ',' or '...' before '<' token
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:256:74: error: 'bool std::operator>=(int)' must have an argument of class or enumerated type
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:10: error: variable or field 'swap' declared void
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:10: error: 'array' was not declared in this scope
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:19: error: expected primary-expression before ',' token
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:27: error: '__one' was not declared in this scope
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:34: error: 'array' was not declared in this scope
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:43: error: expected primary-expression before ',' token
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:262:51: error: '__two' was not declared in this scope
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:9: error: template declaration of 'constexpr _Tp& std::get'
get(array<_Tp, _Nm>& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:9: error: 'array' was not declared in this scope
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:18: error: expected primary-expression before ',' token
get(array<_Tp, _Nm>& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:268:26: error: '__arr' was not declared in this scope
get(array<_Tp, _Nm>& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:9: error: template declaration of 'constexpr _Tp&& std::get'
get(array<_Tp, _Nm>&& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:9: error: 'array' was not declared in this scope
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:18: error: expected primary-expression before ',' token
get(array<_Tp, _Nm>&& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:27: error: label '__arr' referenced outside of any function
get(array<_Tp, _Nm>&& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:277:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:285:15: error: 'array' does not name a type
get(const array<_Tp, _Nm>& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:285:20: error: expected ',' or '...' before '<' token
get(const array<_Tp, _Nm>& __arr) noexcept
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: In function 'constexpr const _Tp& std::get(int)':
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:289:9: error: '__arr' was not declared in this scope
_S_ref(__arr._M_elems, _Int);
^
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:38:0,
from main.cpp:1:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array: At global scope:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:23: error: 'array' is not a member of 'std'
struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:23: error: 'array' is not a member of 'std'
In file included from main.cpp:2:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:50: error: wrong number of template arguments (2, should be 1)
struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:303:11: error: provided for 'template<class _Tp> class std::tuple_size'
class tuple_size;
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:306:53: error: expected unqualified-id before '>' token
struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
^
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:38:0,
from main.cpp:1:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:32: error: 'array' is not a member of 'std'
struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:32: error: 'array' is not a member of 'std'
In file included from main.cpp:2:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:59: error: wrong number of template arguments (3, should be 2)
struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:311:11: error: provided for 'template<unsigned int _Int, class _Tp> class std::tuple_element'
class tuple_element;
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\array:314:62: error: expected unqualified-id before '>' token
struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
^
main.cpp: In function 'int main()':
main.cpp:5:2: error: 'array' is not a member of 'std'
std::array<int,5> vector;
^
main.cpp:5:13: error: expected primary-expression before 'int'
std::array<int,5> vector;
^
main.cpp:5:13: error: expected ';' before 'int'
And clearly from the error, there is a lot of reference to the std::array file that i have included which seems to be the source of the error. What do I do?
Thanks in advance.
EDIT: added compilation commands and g++ version.
Turns out somehow a typo made its way into OP's <array>. What should have been
template<typename _Tp, std::size_t _Nm>
struct array
{
became
template<typename _Tp, std::size_t _Nm>
struct Array
{
Causing a bazillion compiler errors as it tries to process the rest of <array>.
This is a valid C++11 program.
The error you got is most probably due to dialect selection: the C++98 mode does not provide std::array container. See the docs at http://en.cppreference.com/w/cpp/container/array
Specifically, your error comes down to the following:
main.cpp: In function 'int main()':
main.cpp:5:2: error: 'array' is not a member of 'std'
std::array<int,5> vector;
^
main.cpp:5:13: error: expected primary-expression before 'int'
std::array<int,5> vector;
^
main.cpp:5:13: error: expected ';' before 'int'
So, just add -std=c++11 to the command line and things should work.
unable to reproduce with g++ 4.8.1 at Ideone:
the error messages are consistent with not providing option -std=c++11
add that option to the command line