Onnx is not working. AttributeProto is not a name error - c++

I am trying to use onnx in c++ code. But when I try to use onnx/proto_utils.h I am getting
error: 'AttributeProto' does not a name type. I am not sure is it some issue with my installation
or what. I installed onnx from source, using readme.md installation instructions. If anybody
has any clue what is wrong I would appraciate any help.
Onnx installation steps:
git clone https://github.com/onnx/onnx.git
cd onnx
git submodule update --init --recursive
python3 setup.py install
sudo apt-get install protobuf-compiler libprotoc-dev
pip3 install onnx
test.cpp
#include <iostream>
#include "onnx/onnx_pb.h"
#include "onnx/proto_utils.h"
int main()
{
std::cout << "Hello\n";
}
Compilation
g++ -DONNX_ML=1 test.cpp -o test -lprotobuf -I/home/bearnard/onnx/.setuptools-cmake-build/
Error Message
In file included from test.cpp:3:
/usr/local/include/onnx/proto_utils.h:38:65: error: ‘AttributeProto’ does not name a type
38 | template<typename T> inline std::vector<T> RetrieveValues(const AttributeProto& attr);
| ^~~~~~~~~~~~~~
/usr/local/include/onnx/proto_utils.h:39:61: error: ‘AttributeProto’ does not name a type
39 | template<> inline std::vector<int64_t> RetrieveValues(const AttributeProto& attr) {
| ^~~~~~~~~~~~~~
/usr/local/include/onnx/proto_utils.h: In function ‘std::vector<T> ONNX_NAMESPACE::RetrieveValues(const int&) [with T = long int]’:
/usr/local/include/onnx/proto_utils.h:40:16: error: request for member ‘ints’ in ‘attr’, which is of non-class type ‘const int’
40 | return {attr.ints().begin(), attr.ints().end()};
| ^~~~
/usr/local/include/onnx/proto_utils.h:40:37: error: request for member ‘ints’ in ‘attr’, which is of non-class type ‘const int’
40 | return {attr.ints().begin(), attr.ints().end()};
| ^~~~
/usr/local/include/onnx/proto_utils.h:40:49: error: could not convert ‘{<expression error>, <expression error>}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<long int>’
40 | return {attr.ints().begin(), attr.ints().end()};
| ^
| |
| <brace-enclosed initializer list>
/usr/local/include/onnx/proto_utils.h: At global scope:
/usr/local/include/onnx/proto_utils.h:43:65: error: ‘AttributeProto’ does not name a type
43 | template<> inline std::vector<std::string> RetrieveValues(const AttributeProto& attr) {
| ^~~~~~~~~~~~~~
/usr/local/include/onnx/proto_utils.h: In function ‘std::vector<T> ONNX_NAMESPACE::RetrieveValues(const int&) [with T = std::__cxx11::basic_string<char>]’:
/usr/local/include/onnx/proto_utils.h:44:17: error: request for member ‘strings’ in ‘attr’, which is of non-class type ‘const int’
44 | return { attr.strings().begin(), attr.strings().end() };
| ^~~~~~~
/usr/local/include/onnx/proto_utils.h:44:41: error: request for member ‘strings’ in ‘attr’, which is of non-class type ‘const int’
44 | return { attr.strings().begin(), attr.strings().end() };
| ^~~~~~~
/usr/local/include/onnx/proto_utils.h:44:57: error: could not convert ‘{<expression error>, <expression error>}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<std::__cxx11::basic_string<char> >’
44 | return { attr.strings().begin(), attr.strings().end() };
| ^
| |
| <brace-enclosed initializer list>
/usr/local/include/onnx/proto_utils.h: At global scope:
/usr/local/include/onnx/proto_utils.h:47:59: error: ‘AttributeProto’ does not name a type
47 | template<> inline std::vector<float> RetrieveValues(const AttributeProto& attr) {
| ^~~~~~~~~~~~~~
/usr/local/include/onnx/proto_utils.h: In function ‘std::vector<T> ONNX_NAMESPACE::RetrieveValues(const int&) [with T = float]’:
/usr/local/include/onnx/proto_utils.h:48:17: error: request for member ‘floats’ in ‘attr’, which is of non-class type ‘const int’
48 | return { attr.floats().begin(), attr.floats().end() };
| ^~~~~~
/usr/local/include/onnx/proto_utils.h:48:40: error: request for member ‘floats’ in ‘attr’, which is of non-class type ‘const int’
48 | return { attr.floats().begin(), attr.floats().end() };
| ^~~~~~
/usr/local/include/onnx/proto_utils.h:48:55: error: could not convert ‘{<expression error>, <expression error>}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<float>’
48 | return { attr.floats().begin(), attr.floats().end() };
| ^
| |
| <brace-enclosed initializer list>

Related

Error when #include <chrono> in c++14/c++17

I'm trying to include chrono in my project and need support of c++14.
But when I compile it in c++14/c++17, errors occurred.
Code:
#include<chrono>
int main(){return 0;}
Compile it:
gcc test.cc -lstdc++ -std=c++14
Error:
In file included from /usr/include/c++/9/chrono:38,
from test.cc:1:
/usr/include/c++/9/bits/parse_numbers.h:51:50: error: expected template-name before ‘<’ token
51 | struct _Digit<_Base, '0'> : integral_constant<unsigned, 0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:51:50: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:57:50: error: expected template-name before ‘<’ token
57 | struct _Digit<_Base, '1'> : integral_constant<unsigned, 1>
| ^
/usr/include/c++/9/bits/parse_numbers.h:57:50: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:63:43: error: expected template-name before ‘<’ token
63 | struct _Digit_impl : integral_constant<unsigned, _Val>
| ^
/usr/include/c++/9/bits/parse_numbers.h:63:43: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:151:51: error: expected template-name before ‘<’ token
151 | struct _Digit<_Base, '\''> : integral_constant<unsigned, 0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:151:51: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:159:28: error: ‘integral_constant’ does not name a type
159 | using __ull_constant = integral_constant<unsigned long long, _Val>;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/parse_numbers.h:167:4: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
167 | = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:167:52: error: expected unqualified-id before ‘?’ token
167 | = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>;
| ^
/usr/include/c++/9/bits/parse_numbers.h:174:20: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
174 | using type = __ull_constant<__valid_digit::value>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:182:42: error: expected template-name before ‘<’ token
182 | struct _Power<_Base> : __ull_constant<0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:182:42: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:195:20: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
195 | using type = __ull_constant<_Pow * __digit::value + __next::type::value>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:196:22: error: ‘type’ has not been declared
196 | static_assert((type::value / _Pow) == __digit::value,
| ^~~~
/usr/include/c++/9/bits/parse_numbers.h:210:20: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
210 | using type = __ull_constant<_Digit<_Base, _Dig>::value>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:220:21: error: expected template-name before ‘<’ token
220 | : __ull_constant<0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:220:21: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:268:20: error: expected template-name before ‘<’ token
268 | : conditional_t<(_Val <= std::numeric_limits<_IntType>::max()),
| ^
/usr/include/c++/9/bits/parse_numbers.h:268:20: error: expected ‘{’ before ‘<’ token
#root ➜ proof_of_work git(master)  gcc test.cc -lstdc++ -std=c++14
In file included from /usr/include/c++/9/chrono:38,
from test.cc:1:
/usr/include/c++/9/bits/parse_numbers.h:51:50: error: expected template-name before ‘<’ token
51 | struct _Digit<_Base, '0'> : integral_constant<unsigned, 0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:51:50: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:57:50: error: expected template-name before ‘<’ token
57 | struct _Digit<_Base, '1'> : integral_constant<unsigned, 1>
| ^
/usr/include/c++/9/bits/parse_numbers.h:57:50: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:63:43: error: expected template-name before ‘<’ token
63 | struct _Digit_impl : integral_constant<unsigned, _Val>
| ^
/usr/include/c++/9/bits/parse_numbers.h:63:43: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:151:51: error: expected template-name before ‘<’ token
151 | struct _Digit<_Base, '\''> : integral_constant<unsigned, 0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:151:51: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:159:28: error: ‘integral_constant’ does not name a type
159 | using __ull_constant = integral_constant<unsigned long long, _Val>;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/parse_numbers.h:167:4: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
167 | = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:167:52: error: expected unqualified-id before ‘?’ token
167 | = __ull_constant<__next::value * (__valid_digit{} ? _Base : 1ULL)>;
| ^
/usr/include/c++/9/bits/parse_numbers.h:174:20: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
174 | using type = __ull_constant<__valid_digit::value>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:182:42: error: expected template-name before ‘<’ token
182 | struct _Power<_Base> : __ull_constant<0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:182:42: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:195:20: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
195 | using type = __ull_constant<_Pow * __digit::value + __next::type::value>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:196:22: error: ‘type’ has not been declared
196 | static_assert((type::value / _Pow) == __digit::value,
| ^~~~
/usr/include/c++/9/bits/parse_numbers.h:210:20: error: ‘__ull_constant’ does not name a type; did you mean ‘__builtin_constant_p’?
210 | using type = __ull_constant<_Digit<_Base, _Dig>::value>;
| ^~~~~~~~~~~~~~
| __builtin_constant_p
/usr/include/c++/9/bits/parse_numbers.h:220:21: error: expected template-name before ‘<’ token
220 | : __ull_constant<0>
| ^
/usr/include/c++/9/bits/parse_numbers.h:220:21: error: expected ‘{’ before ‘<’ token
/usr/include/c++/9/bits/parse_numbers.h:268:20: error: expected template-name before ‘<’ token
268 | : conditional_t<(_Val <= std::numeric_limits<_IntType>::max()),
| ^
/usr/include/c++/9/bits/parse_numbers.h:268:20: error: expected ‘{’ before ‘<’ token
Besides:
no error when using c++11.
use clang++ also has same problem
I compile it on wsl(ubuntu 20.04)
So how to fix it?

Don't understand this problem with ranges::v3

I have the following code fragment using ranges::v3:
#include <range/v3/view/all.hpp>
#include <range/v3/view/filter.hpp>
#include <range/v3/view/join.hpp>
#include <range/v3/range/conversion.hpp>
#include <unordered_map>
#include <limits>
#include <stdint.h>
#include <sys/socket.h>
#include <string>
struct EncodedValueDecoder: std::unordered_map<int, uint8_t> {
using Base_t = std::unordered_map<int, uint8_t>;
EncodedValueDecoder(int mask, const Base_t& values) :
Base_t(values), mask_(mask == 0 ? std::numeric_limits<int>::max() : mask) {
}
std::string findAll(const int target) const {
return *this | ranges::views::filter([&target, this](const typename Base_t::value_type& item) {
return bitSet(item.first, target);
}) | ranges::views::join(",") | ranges::to<std::string>();
}
int maskedValue(const int target) const {
return static_cast<int>(target & mask_);
}
bool bitSet(const int bit, const int target) const {
return bit & target & mask_;
}
int mask_;
};
I get the following errors
g++ -std=c++23 -O0 -g3 -pedantic -pedantic-errors -Wall -Wextra -Werror -Wconversion -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wlogical-op -Wmissing-declarations -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wshadow -Wsign-conversion -Wsign-promo -Wswitch-default -Wfloat-equal -c -pthread -Winvalid-pch -fmessage-length=0 -Wdouble-promotion -Wimplicit-fallthrough=5 -Wuninitialized -Winit-self -Wsuggest-override -Wduplicated-branches -Wduplicated-cond -Wtrampolines -Wcast-qual -Wuseless-cast -Wsized-deallocation -ftemplate-backtrace-limit=0 -fPIC -o src/main.o ../src/main.cpp
../src/main.cpp: In member function ‘std::string EncodedValueDecoder::findAll(int) const’:
../src/main.cpp:20:20: error: no match for ‘operator|’ (operand types are ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ and ‘ranges::views::view_closure<ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char [2]> > >’)
18 | return *this | ranges::views::filter([&target, this](const typename Base_t::value_type& item) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >
19 | return bitSet(item.first, target);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 | }) | ranges::views::join(",") | ranges::to<std::string>();
| ~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
| |
| ranges::views::view_closure<ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char [2]> > >
In file included from /usr/include/range/v3/view/all.hpp:28,
from ../src/main.cpp:1:
/usr/include/range/v3/view/view.hpp:142:35: note: candidate: ‘template<class ViewFn, class Pipeable> constexpr concepts::return_t<ranges::views::view_closure<ranges::composed<Pipeable, ViewFn> >, typename std::enable_if<(is_pipeable_v<Pipeable> && concepts::detail::CPP_true_fn(concepts::detail::Nil{})), void>::type> ranges::views::view_closure_base_ns::operator|(ranges::views::view_closure<Fun>, Pipeable)’
142 | friend constexpr auto operator|(view_closure<ViewFn> vw, Pipeable pipe)
| ^~~~~~~~
/usr/include/range/v3/view/view.hpp:142:35: note: template argument deduction/substitution failed:
../src/main.cpp:20:45: note: ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ is not derived from ‘ranges::views::view_closure<Fun>’
20 | }) | ranges::views::join(",") | ranges::to<std::string>();
| ^
/usr/include/range/v3/view/view.hpp:127:13: note: candidate: ‘template<class Rng, class ViewFn> constexpr concepts::return_t<Rng, typename std::enable_if<((range<Rng> && (! viewable_range<Rng>)) && concepts::detail::CPP_true_fn(concepts::detail::Nil{})), void>::type> ranges::views::view_closure_base_ns::operator|(Rng&&, const ranges::views::view_closure<ViewFn>&)’ (deleted)
127 | operator|(Rng &&, view_closure<ViewFn> const &) // ******* READ THIS ********
| ^~~~~~~~
/usr/include/range/v3/view/view.hpp:127:13: note: template argument deduction/substitution failed:
/usr/include/range/v3/view/view.hpp: In substitution of ‘template<class Rng, class ViewFn> constexpr concepts::return_t<Rng, typename std::enable_if<((range<Rng> && (! viewable_range<Rng>)) && concepts::detail::CPP_true_fn(concepts::detail::Nil{})), void>::type> ranges::views::view_closure_base_ns::operator|(Rng&&, const ranges::views::view_closure<ViewFn>&) [with Rng = ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >; ViewFn = ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char [2]> >]’:
../src/main.cpp:20:31: required from here
/usr/include/range/v3/view/view.hpp:127:13: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
/usr/include/range/v3/view/view.hpp:117:35: note: candidate: ‘template<class Rng, class ViewFn> requires (viewable_range<Rng>) && (invocable_view_closure<ViewFn, Rng>) constexpr auto ranges::views::view_closure_base_ns::operator|(Rng&&, ranges::views::view_closure<ViewFn>)’
117 | friend constexpr auto operator|(Rng && rng, view_closure<ViewFn> vw)
| ^~~~~~~~
/usr/include/range/v3/view/view.hpp:117:35: note: template argument deduction/substitution failed:
/usr/include/range/v3/view/view.hpp:117:35: note: constraints not satisfied
In file included from /usr/include/range/v3/range_fwd.hpp:22,
from /usr/include/range/v3/view/all.hpp:20:
/usr/include/range/v3/functional/concepts.hpp: In substitution of ‘template<class Rng, class ViewFn> requires (viewable_range<Rng>) && (invocable_view_closure<ViewFn, Rng>) constexpr auto ranges::views::view_closure_base_ns::operator|(Rng&&, ranges::views::view_closure<ViewFn>) [with Rng = ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >; ViewFn = ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char [2]> >]’:
../src/main.cpp:20:31: required from here
/usr/include/range/v3/functional/concepts.hpp:40:5: required for the satisfaction of ‘invocable_requires_<Fun, Args ...>’ [with Fun = ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char[2]> >; Args = {ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll::._anon_127>}]
/usr/include/range/v3/functional/concepts.hpp:48:17: required for the satisfaction of ‘invocable<ViewFn, Rng>’ [with ViewFn = ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char[2]> >; Rng = ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll::._anon_127>]
/usr/include/range/v3/view/view.hpp:83:17: required for the satisfaction of ‘invocable_view_closure<ViewFn, Rng>’ [with ViewFn = ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char[2]> >; Rng = ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll::._anon_127>]
/usr/include/range/v3/functional/concepts.hpp:40:5: in requirements with ‘Fun&& fn’ [with Args = {ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll::._anon_127>}; Fun = ranges::detail::bind_back_fn_<ranges::views::join_base_fn, ranges::detail::reference_wrapper_<const char[2]> >]
/usr/include/range/v3/functional/concepts.hpp:40:5: note: the required expression ‘ranges::invoke((Fun&&)(fn), (declval<Args>)()...)’ is invalid
40 | CPP_requires(invocable_,
| ^~~~~~~~~~~~
cc1plus: note: set ‘-fconcepts-diagnostics-depth=’ to at least 2 for more detail
In file included from /usr/include/meta/meta.hpp:18,
from /usr/include/range/v3/view/all.hpp:18:
/usr/include/c++/12.1.0/cstddef:132:3: note: candidate: ‘constexpr std::byte std::operator|(byte, byte)’
132 | operator|(byte __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/12.1.0/cstddef:132:18: note: no known conversion for argument 1 from ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ to ‘std::byte’
132 | operator|(byte __l, byte __r) noexcept
| ~~~~~^~~
In file included from /usr/include/c++/12.1.0/streambuf:41,
from /usr/include/c++/12.1.0/bits/streambuf_iterator.h:35,
from /usr/include/c++/12.1.0/iterator:66,
from /usr/include/range/v3/range/access.hpp:21,
from /usr/include/range/v3/view/all.hpp:22:
/usr/include/c++/12.1.0/bits/ios_base.h:87:3: note: candidate: ‘constexpr std::_Ios_Fmtflags std::operator|(_Ios_Fmtflags, _Ios_Fmtflags)’
87 | operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
| ^~~~~~~~
/usr/include/c++/12.1.0/bits/ios_base.h:87:27: note: no known conversion for argument 1 from ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ to ‘std::_Ios_Fmtflags’
87 | operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/12.1.0/bits/ios_base.h:130:3: note: candidate: ‘constexpr std::_Ios_Openmode std::operator|(_Ios_Openmode, _Ios_Openmode)’
130 | operator|(_Ios_Openmode __a, _Ios_Openmode __b)
| ^~~~~~~~
/usr/include/c++/12.1.0/bits/ios_base.h:130:27: note: no known conversion for argument 1 from ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ to ‘std::_Ios_Openmode’
130 | operator|(_Ios_Openmode __a, _Ios_Openmode __b)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/12.1.0/bits/ios_base.h:170:3: note: candidate: ‘constexpr std::_Ios_Iostate std::operator|(_Ios_Iostate, _Ios_Iostate)’
170 | operator|(_Ios_Iostate __a, _Ios_Iostate __b)
| ^~~~~~~~
/usr/include/c++/12.1.0/bits/ios_base.h:170:26: note: no known conversion for argument 1 from ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ to ‘std::_Ios_Iostate’
170 | operator|(_Ios_Iostate __a, _Ios_Iostate __b)
| ~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/12.1.0/bits/shared_ptr_atomic.h:33,
from /usr/include/c++/12.1.0/memory:78,
from /usr/include/range/v3/utility/addressof.hpp:15,
from /usr/include/range/v3/iterator/basic_iterator.hpp:29,
from /usr/include/range/v3/iterator/reverse_iterator.hpp:20,
from /usr/include/range/v3/range/access.hpp:37:
/usr/include/c++/12.1.0/bits/atomic_base.h:98:3: note: candidate: ‘constexpr std::memory_order std::operator|(memory_order, __memory_order_modifier)’
98 | operator|(memory_order __m, __memory_order_modifier __mod)
| ^~~~~~~~
/usr/include/c++/12.1.0/bits/atomic_base.h:98:26: note: no known conversion for argument 1 from ‘ranges::filter_view<ranges::ref_view<const EncodedValueDecoder>, EncodedValueDecoder::findAll(int) const::<lambda(const std::unordered_map<int, unsigned char>::value_type&)> >’ to ‘std::memory_order’
98 | operator|(memory_order __m, __memory_order_modifier __mod)
| ~~~~~~~~~~~~~^~~
../src/main.cpp: In member function ‘int EncodedValueDecoder::maskedValue(int) const’:
../src/main.cpp:23:24: error: useless cast to type ‘int’ [-Werror=useless-cast]
23 | return static_cast<int>(target & mask_);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
It appears to be complaining about the absence of a suitable overload for operator|. Given that I adapted this code from some examples I've seen in blogs dealing with ranges::v3, I've obviously misunderstood something. Can anyone point out my error?
The code I've posted is nonsense which is why it wouldn't compile. Kudos to JaMiT. If I could find a way to award a gold star, I would.

Can't compile OpenCV header files in CLion

I recently installed OpenCV on my Ubuntu system. I used instructions from here and here to install OpenCV c++.
When I include the opencv header in my file:
#include <opencv2/opencv.hpp>
It gives me the following error while building:
note: ‘cv::Range’ declared here
589 | class CV_EXPORTS Range
| ^~~~~
In file included from /usr/local/include/opencv4/opencv2/core.hpp:59,
from /usr/local/include/opencv4/opencv2/core/core.hpp:48,
from /home/mo/CLionProjects/DisjointForest/main.cpp:4:
/usr/local/include/opencv4/opencv2/core/mat.hpp:1640:43: error: template argument 1 is invalid
1640 | Mat operator()(const std::vector<Range>& ranges) const;
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1640:43: error: template argument 2 is invalid
/usr/local/include/opencv4/opencv2/core/mat.hpp:1640:9: error: ‘Mat Mat::operator()(const int&) const’ cannot be overloaded with ‘Mat Mat::operator()(const int&) const’
1640 | Mat operator()(const std::vector<Range>& ranges) const;
| ^~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1630:9: note: previous declaration ‘Mat Mat::operator()(const int&) const’
1630 | Mat operator()( const Rect& roi ) const;
| ^~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1643:44: error: expected type-specifier
1643 | template<typename _Tp, int n> operator Vec<_Tp, n>() const;
| ^~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1644:51: error: expected type-specifier
1644 | template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
| ^~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1850:38: error: ‘Vec’ does not name a type
1850 | template<int n> uchar* ptr(const Vec<int, n>& idx);
| ^~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1850:41: error: expected ‘,’ or ‘...’ before ‘<’ token
1850 | template<int n> uchar* ptr(const Vec<int, n>& idx);
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1852:44: error: ‘Vec’ does not name a type
1852 | template<int n> const uchar* ptr(const Vec<int, n>& idx) const;
| ^~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1852:47: error: expected ‘,’ or ‘...’ before ‘<’ token
1852 | template<int n> const uchar* ptr(const Vec<int, n>& idx) const;
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1877:50: error: ‘Vec’ does not name a type
1877 | template<typename _Tp, int n> _Tp* ptr(const Vec<int, n>& idx);
| ^~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1877:53: error: expected ‘,’ or ‘...’ before ‘<’ token
1877 | template<typename _Tp, int n> _Tp* ptr(const Vec<int, n>& idx);
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1879:56: error: ‘Vec’ does not name a type
1879 | template<typename _Tp, int n> const _Tp* ptr(const Vec<int, n>& idx) const;
| ^~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1879:59: error: expected ‘,’ or ‘...’ before ‘<’ token
1879 | template<typename _Tp, int n> const _Tp* ptr(const Vec<int, n>& idx) const;
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1950:49: error: ‘Vec’ does not name a type
1950 | template<typename _Tp, int n> _Tp& at(const Vec<int, n>& idx);
| ^~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1950:52: error: expected ‘,’ or ‘...’ before ‘<’ token
1950 | template<typename _Tp, int n> _Tp& at(const Vec<int, n>& idx);
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1952:55: error: ‘Vec’ does not name a type
1952 | template<typename _Tp, int n> const _Tp& at(const Vec<int, n>& idx) const;
| ^~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:1952:58: error: expected ‘,’ or ‘...’ before ‘<’ token
1952 | template<typename _Tp, int n> const _Tp& at(const Vec<int, n>& idx) const;
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1958:36: error: ‘Point’ was not declared in this scope; did you mean ‘cv::Point’?
1958 | template<typename _Tp> _Tp& at(Point pt);
| ^~~~~
| cv::Point
In file included from /usr/local/include/opencv4/opencv2/core.hpp:58,
from /usr/local/include/opencv4/opencv2/core/core.hpp:48,
from /home/mo/CLionProjects/DisjointForest/main.cpp:4:
/usr/local/include/opencv4/opencv2/core/types.hpp:194:17: note: ‘cv::Point’ declared here
194 | typedef Point2i Point;
| ^~~~~
In file included from /usr/local/include/opencv4/opencv2/core.hpp:59,
from /usr/local/include/opencv4/opencv2/core/core.hpp:48,
from /home/mo/CLionProjects/DisjointForest/main.cpp:4:
/usr/local/include/opencv4/opencv2/core/mat.hpp:1958:45: error: data member ‘at’ cannot be a member template
1958 | template<typename _Tp> _Tp& at(Point pt);
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:1963:42: error: ‘Point’ was not declared in this scope; did you mean ‘cv::Point’?
1963 | template<typename _Tp> const _Tp& at(Point pt) const;
| ^~~~~
| cv::Point
In file included from /usr/local/include/opencv4/opencv2/core.hpp:58,
from /usr/local/include/opencv4/opencv2/core/core.hpp:48,
from /home/mo/CLionProjects/DisjointForest/main.cpp:4:
/usr/local/include/opencv4/opencv2/core/types.hpp:194:17: note: ‘cv::Point’ declared here
194 | typedef Point2i Point;
| ^~~~~
In file included from /usr/local/include/opencv4/opencv2/core.hpp:59,
from /usr/local/include/opencv4/opencv2/core/core.hpp:48,
from /home/mo/CLionProjects/DisjointForest/main.cpp:4:
/usr/local/include/opencv4/opencv2/core/mat.hpp:1963:51: error: expected ‘;’ before ‘const’
1963 | template<typename _Tp> const _Tp& at(Point pt) const;
| ^~~~~~
| ;
/usr/local/include/opencv4/opencv2/core/mat.hpp:1963:57: error: data member ‘at’ cannot be a member template
1963 | template<typename _Tp> const _Tp& at(Point pt) const;
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:2001:28: error: ‘MatIterator_’ does not name a type
2001 | template<typename _Tp> MatIterator_<_Tp> begin();
| ^~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2002:28: error: ‘MatConstIterator_’ does not name a type
2002 | template<typename _Tp> MatConstIterator_<_Tp> begin() const;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2009:28: error: ‘MatIterator_’ does not name a type
2009 | template<typename _Tp> MatIterator_<_Tp> end();
| ^~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2010:28: error: ‘MatConstIterator_’ does not name a type
2010 | template<typename _Tp> MatConstIterator_<_Tp> end() const;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:957:68: error: ‘Range’ has not been declared
957 | Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all());
| ^~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2181:22: error: expected nested-name-specifier before ‘DataType’
2181 | typedef typename DataType<_Tp>::channel_type channel_type;
| ^~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2181:22: error: expected ‘;’ at end of member declaration
2181 | typedef typename DataType<_Tp>::channel_type channel_type;
| ^~~~~~~~
| ;
/usr/local/include/opencv4/opencv2/core/mat.hpp:2181:30: error: expected unqualified-id before ‘<’ token
2181 | typedef typename DataType<_Tp>::channel_type channel_type;
| ^
/usr/local/include/opencv4/opencv2/core/mat.hpp:2182:13: error: ‘MatIterator_’ does not name a type
2182 | typedef MatIterator_<_Tp> iterator;
| ^~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2183:13: error: ‘MatConstIterator_’ does not name a type
2183 | typedef MatConstIterator_<_Tp> const_iterator;
| ^~~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2192:23: error: expected ‘)’ before ‘_size’
2192 | explicit Mat_(Size _size);
| ~ ^~~~~~
| )
/usr/local/include/opencv4/opencv2/core/mat.hpp:2194:14: error: expected ‘)’ before ‘_size’
2194 | Mat_(Size _size, const _Tp& value);
| ~ ^~~~~~
| )
/usr/local/include/opencv4/opencv2/core/mat.hpp:2208:31: error: ‘Range’ does not name a type
2208 | Mat_(const Mat_& m, const Range& rowRange, const Range& colRange=Range::all());
| ^~~~~
/usr/local/include/opencv4/opencv2/core/mat.hpp:2208:54: error: ‘Range’ does not name a type
2208 | Mat_(const Mat_& m, const Range& rowRange, const Range& colRange=Range::all());
| ^~~~~
.....................
.....................
In file included from /usr/local/include/opencv4/opencv2/core.hpp:3294,
from /usr/local/include/opencv4/opencv2/core/core.hpp:48,
from /home/mo/CLionProjects/DisjointForest/main.cpp:4:
/usr/local/include/opencv4/opencv2/core/optim.hpp:296:26: error: ‘InputArray’ was not declared in this scope; did you mean ‘OutputArray’?
296 | CV_EXPORTS_W int solveLP(InputArray Func, InputArray Constr, OutputArray z);
| ^~~~~~~~~~
| OutputArray
/usr/local/include/opencv4/opencv2/core/optim.hpp:296:43: error: ‘InputArray’ was not declared in this scope; did you mean ‘OutputArray’?
296 | CV_EXPORTS_W int solveLP(InputArray Func, InputArray Constr, OutputArray z);
| ^~~~~~~~~~
| OutputArray
/usr/local/include/opencv4/opencv2/core/optim.hpp:296:74: error: expected primary-expression before ‘z’
296 | CV_EXPORTS_W int solveLP(InputArray Func, InputArray Constr, OutputArray z);
| ^
/usr/local/include/opencv4/opencv2/core/optim.hpp:296:75: error: expression list treated as compound expression in initializer [-fpermissive]
296 | CV_EXPORTS_W int solveLP(InputArray Func, InputArray Constr, OutputArray z);
| ^
make[3]: *** [CMakeFiles/DisjointForest.dir/build.make:63: CMakeFiles/DisjointForest.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/DisjointForest.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/DisjointForest.dir/rule] Error 2
make: *** [Makefile:118: DisjointForest] Error 2
I have no idea what this error means. Could someone please guide me how I can fix this error and starting working with openCV?
If it helps, here's my cmake file:
cmake_minimum_required(VERSION 3.16)
project(DisjointForest)
set(CMAKE_CXX_STANDARD 20)
find_package(OpenCV 4.3.0 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(DisjointForest main.cpp LinkedListDisjointSet.cpp DisjointForest.cpp DisjointForest.h)
target_link_directories(DisjointForest PUBLIC ${OpenCV_LIBS})
Okay so after a lot of research about linkers and linking libraries, I've realized the two problems:
1) Changing c++ 20 to c++ 17 compiled the header files. Perhaps the library is not compatible with c++20 yet.
2) Changing the above won't suffice as we have still not correctly linked the libraries. It will still give unresolved error. In my cmake file I need to replace the target_link_directories() with target_link_libraries(). This was a silly mistake I made while following the instructions from the links in the question.

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.

How to extract types and names from CXXMemberCallExpr?

I would like to extract the types and names of the entire caller object and parameter types of member call expressions made from the A::WriteData method definition.
class ostream {
public:
void write(char* c, unsigned int i) {
}
};
struct StringWrapper {
char c[30];
void Write(ostream& os) {
os.write((char*)&c, sizeof(c));
}
};
struct DoubleWrapper {
double d;
void Write(ostream& os) {
os.write((char*)&d, sizeof(d));
}
};
struct Data {
DoubleWrapper dw;
int i;
StringWrapper sw;
};
class A {
public:
void WriteData(ostream& os);
private:
Data* d;
};
void A::WriteData(ostream& os) {
os.write((char*)&d->i, sizeof(d->i));
d->dw.Write(os);
d->sw.Write(os);
}
The relevant part of clang's AST for the WriteData method is here-
`-CXXMethodDecl 0x1221980 parent 0x1221628 prev 0x12217f8 <line:29:1, line:33:1> line:29:9 WriteData 'void (class ostream &) __attribute__((thiscall))'
|-ParmVarDecl 0x1221908 <col:19, col:28> col:28 used os 'class ostream &'
`-CompoundStmt 0x1221d90 <col:32, line:33:1>
|-CXXMemberCallExpr 0x1221bc8 <line:30:5, col:40> 'void'
| |-MemberExpr 0x1221a30 <col:5, col:8> '<bound member function type>' .write 0x418a10
| | `-DeclRefExpr 0x1221a18 <col:5> 'class ostream' lvalue ParmVar 0x1221908 'os' 'class ostream &'
| |-CStyleCastExpr 0x1221b10 <col:14, col:25> 'char *' <BitCast>
| | `-UnaryOperator 0x1221ae8 <col:21, col:25> 'int *' prefix '&'
| | `-MemberExpr 0x1221aa0 <col:22, col:25> 'int' lvalue ->i 0x12215b0
| | `-ImplicitCastExpr 0x1221a90 <col:22> 'struct Data *' <LValueToRValue>
| | `-MemberExpr 0x1221a68 <col:22> 'struct Data *' lvalue ->d 0x12218a8
| | `-CXXThisExpr 0x1221a58 <col:22> 'class A *' this
| `-UnaryExprOrTypeTraitExpr 0x1221bb0 <col:28, col:39> 'unsigned int' sizeof
| `-ParenExpr 0x1221b98 <col:34, col:39> 'int' lvalue
| `-MemberExpr 0x1221b70 <col:35, col:38> 'int' lvalue ->i 0x12215b0
| `-ImplicitCastExpr 0x1221b60 <col:35> 'struct Data *' <LValueToRValue>
| `-MemberExpr 0x1221b38 <col:35> 'struct Data *' lvalue ->d 0x12218a8
| `-CXXThisExpr 0x1221b28 <col:35> 'class A *' this
|-CXXMemberCallExpr 0x1221ca0 <line:31:5, col:19> 'void'
| |-MemberExpr 0x1221c60 <col:5, col:11> '<bound member function type>' .Write 0x1221248
| | `-MemberExpr 0x1221c38 <col:5, col:8> 'struct DoubleWrapper' lvalue ->dw 0x1221570
| | `-ImplicitCastExpr 0x1221c28 <col:5> 'struct Data *' <LValueToRValue>
| | `-MemberExpr 0x1221c00 <col:5> 'struct Data *' lvalue ->d 0x12218a8
| | `-CXXThisExpr 0x1221bf0 <col:5> 'class A *' this
| `-DeclRefExpr 0x1221c88 <col:17> 'class ostream' lvalue ParmVar 0x1221908 'os' 'class ostream &'
`-CXXMemberCallExpr 0x1221d70 <line:32:5, col:19> 'void'
|-MemberExpr 0x1221d30 <col:5, col:11> '<bound member function type>' .Write 0x418d20
| `-MemberExpr 0x1221d08 <col:5, col:8> 'struct StringWrapper' lvalue ->sw 0x12215e8
| `-ImplicitCastExpr 0x1221cf8 <col:5> 'struct Data *' <LValueToRValue>
| `-MemberExpr 0x1221cd0 <col:5> 'struct Data *' lvalue ->d 0x12218a8
| `-CXXThisExpr 0x1221cc0 <col:5> 'class A *' this
`-DeclRefExpr 0x1221d58 <col:17> 'class ostream' lvalue ParmVar 0x1221908 'os' 'class ostream &'
In this case, the information I want from my matcher would be:
caller=os: ostream ; params= &d->i: int*, sizeof(d->i): size_t
caller=d->dw: DoubleWrapper ; params= os: ostream
caller=d->sw: StringWrapper ; params= os: ostream
I've tried the following matcher:
cxxMemberCallExpr(
allOf(
hasAncestor(
cxxMethodDecl(isDefinition(),
hasName("WriteData"))),
anyOf(callee(cxxMethodDecl(hasName("WriteData"))),
callee(cxxMethodDecl(hasName("write"))))
)).bind("write-call-expr")
This gives me the correct statements that I want to extract.
I've extracted the following (invalid c++ follows):
Parameter types by getting the QualType of the parameters as a
string:
cxxMemberCallExpr->getDirectCallee()->parameters()
The argument names:
cxxMemberCallExpr->getArg(i)->printPretty(...) // **is there a better way to do this?**
Type of the object caller:
cxxMemberCallExpr->getImplicitObjectArgument()->getType().getAsString()
Object caller method:
dyn_cast<MemberExpr>(cxxMemberCallExpr->getCallee())
->getMemberNameInfo().getName().getAsString()
How do I get the object caller itself?
Is there a better way to get the argument names that are passed to the Write methods?
Looking at the AST, I'm not sure where to start.