Consider this code:
#include <iostream>
template<class C>
struct time { };
int main() { }
It produces (GCC 4.5):
error: ‘template<class C> struct time’ redeclared as different kind of symbol
/usr/include/time.h:186:15: error: previous declaration of ‘time_t time(time_t*)’
Why does iostream include time_t time(time_t*) ?
Why does iostream include time_t time(time_t*) outside std namespace?
(unanswered) Why, if I remove template<class C>, do I not get this error?
If you run g++ -H -Wall -c testim.cc (where testim.cc is your example) you'll see that
.... /usr/include/c++/4.6/bits/ios_base.h
..... /usr/include/c++/4.6/ext/atomicity.h
...... /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr.h
....... /usr/include/c++/4.6/x86_64-linux-gnu/./bits/gthr-default.h
........ /usr/include/pthread.h
......... /usr/include/sched.h
.......... /usr/lib/gcc/x86_64-linux-gnu/4.6/include/stddef.h
.......... /usr/include/time.h
So <time.h> is included for pthread support.
This is with GCC 4.6 on Debian/Sid/AMD64
Seems to be for locale support on my box:
$ cat whytime.cc
#define _TIME_H_
#include <iostream>
int main() {
std::cout << "hello, world" << std::endl;
return 0;
}
$ g++ -Wall -Werror -Wextra -ansi -o whytime whytime.cc && ./whytime
In file included from /usr/include/c++/4.2.1/cwchar:52,
from /usr/include/c++/4.2.1/bits/postypes.h:46,
from /usr/include/c++/4.2.1/iosfwd:49,
from /usr/include/c++/4.2.1/ios:43,
from /usr/include/c++/4.2.1/ostream:45,
from /usr/include/c++/4.2.1/iostream:45,
from whytime.cc:2:
/usr/include/c++/4.2.1/ctime:66: error: ‘::clock_t’ has not been declared
/usr/include/c++/4.2.1/ctime:68: error: ‘::tm’ has not been declared
/usr/include/c++/4.2.1/ctime:70: error: ‘::clock’ has not been declared
/usr/include/c++/4.2.1/ctime:71: error: ‘::difftime’ has not been declared
/usr/include/c++/4.2.1/ctime:72: error: ‘::mktime’ has not been declared
/usr/include/c++/4.2.1/ctime:73: error: ‘::time’ has not been declared
/usr/include/c++/4.2.1/ctime:74: error: ‘::asctime’ has not been declared
/usr/include/c++/4.2.1/ctime:75: error: ‘::ctime’ has not been declared
/usr/include/c++/4.2.1/ctime:76: error: ‘::gmtime’ has not been declared
/usr/include/c++/4.2.1/ctime:77: error: ‘::localtime’ has not been declared
/usr/include/c++/4.2.1/ctime:78: error: ‘::strftime’ has not been declared
In file included from /usr/include/c++/4.2.1/locale:46,
from /usr/include/c++/4.2.1/bits/ostream.tcc:46,
from /usr/include/c++/4.2.1/ostream:572,
from /usr/include/c++/4.2.1/iostream:45,
from whytime.cc:2:
/usr/include/c++/4.2.1/bits/locale_facets.tcc: In member function ‘_InIter std::time_get<_CharT, _InIter>::_M_extract_via_format(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*, const _CharT*) const’:
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1839: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1846: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1854: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1861: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1873: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1880: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1883: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1895: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1900: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1908: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1912: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1932: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1968: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc:1976: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc: In member function ‘virtual _InIter std::time_get<_CharT, _InIter>::do_get_weekday(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*) const’:
/usr/include/c++/4.2.1/bits/locale_facets.tcc:2210: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc: In member function ‘virtual _InIter std::time_get<_CharT, _InIter>::do_get_monthname(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*) const’:
/usr/include/c++/4.2.1/bits/locale_facets.tcc:2259: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
/usr/include/c++/4.2.1/bits/locale_facets.tcc: In member function ‘virtual _InIter std::time_get<_CharT, _InIter>::do_get_year(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, tm*) const’:
/usr/include/c++/4.2.1/bits/locale_facets.tcc:2288: error: invalid use of incomplete type ‘struct tm’
/usr/include/wchar.h:152: error: forward declaration of ‘struct tm’
Apparently GCC's iostream needs something in time for something.
time_t is a C language thing, which doesn't have namespaces, and so for backwards comparability-ish, it is in both the std namespace, and not in the std namespace.
As for why there's no errors, I'm not 100% sure. I know C could have functions and structs with the same name, and structs were qualified with the name struct so that the compiler could tell them apart. C++ compilers thinks it's a function, unless preceeded with the struct keyword. http://ideone.com/XZB2M v http://ideone.com/kWMKE. I guess it also allows that for backwards comparability?
Related
The G++ complier is not working. Yesterday I was updating MinGW and Windows PATHS to get Natbeans working but now Visual Studio Code is not Saying "Hello World", It is giving 20+ errors each run.
Any ideas on how to fix so I can run my program? I Uninstalled and Reinstalled MinGw twice but it did not work
Some of the Errors:
required from 'class std::__cxx11::basic_string<char16_t>'
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5677:41:
required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:61:53:
error: no type named 'size_type' in 'struct
std::allocator_traitsstd::allocator<char16_t >'
typedef typename _Base_type::size_type size_type;
^~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:62:53:
error: no type named 'difference_type' in 'struct
std::allocator_traitsstd::allocator<char16_t >'
typedef typename _Base_type::difference_type difference_type;
^~~~~~~~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:70:23:
error: no members matching
'__gnu_cxx::__alloc_traitsstd::allocator<char16_t >::_Base_type {aka
std::allocator_traitsstd::allocator<char16_t >}::max_size' in
'__gnu_cxx::__alloc_traitsstd::allocator<char16_t >::_Base_type {aka
struct std::allocator_traitsstd::allocator<char16_t >}'
using _Base_type::max_size;
^~~~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h: In
member function 'size_t std::hashstd::__cxx11::basic_string<char16_t
::operator()(const u16string&) const': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5678:42:
error: 'const u16string {aka const class
std::__cxx11::basic_string<char16_t>}' has no member named 'length'
__s.length() * sizeof(char16_t)); }
^~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:40:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h: In
instantiation of 'struct
__gnu_cxx::__alloc_traitsstd::allocator<char32_t >': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:75:24:
required from 'class std::__cxx11::basic_string<char32_t>'
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5692:41:
required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:61:53:
error: no type named 'size_type' in 'struct
std::allocator_traitsstd::allocator<char32_t >'
typedef typename _Base_type::size_type size_type;
^~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:62:53:
error: no type named 'difference_type' in 'struct
std::allocator_traitsstd::allocator<char32_t >'
typedef typename _Base_type::difference_type difference_type;
^~~~~~~~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:70:23:
error: no members matching
'__gnu_cxx::__alloc_traitsstd::allocator<char32_t >::_Base_type {aka
std::allocator_traitsstd::allocator<char32_t >}::max_size' in
'__gnu_cxx::__alloc_traitsstd::allocator<char32_t >::_Base_type {aka
struct std::allocator_traitsstd::allocator<char32_t >}'
using _Base_type::max_size;
^~~~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h: In
member function 'size_t std::hashstd::__cxx11::basic_string<char32_t
::operator()(const u32string&) const': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5693:42:
error: 'const u32string {aka const class
std::__cxx11::basic_string<char32_t>}' has no member named 'length'
The Code so far (Want it to print Hello World to the Console using C++):
#include <iostream>
int main()
{
//Prints Hello World to the Console
std::cout << "Hello World" << std::endl;
}
Desired output:
"Hello World"
In my project I have the following piece of code, which works perfectly fine:
#include <optional>
#include <ostream>
using optional_stream_ref = std::optional<std::reference_wrapper<std::ostream>>;
which is then used in functions such as this:
template<typename State, typename Matrix>
inline auto state_energy(const State& state, Matrix& matrix, optional_stream_ref out = std::nullopt) -> typename State::energy_t
{
typename State::energy_t energy = state.calc_energy(matrix, out);
return energy;
}
This compiles and works.
But for some reason when I try to do it in vacuum, just testing, it doesn't compile.
This is main.cpp example:
#include<optional>
#include<ostream>
using optional_stream_ref = std::optional<std::reference_wrapper<std::ostream>>;
void f(int a, optional_stream_ref out = std::nullopt)
{
}
int main()
{
}
which gives this compilation error:
g++ -std=c++17 -O3 -pedantic -Wall -Wextra -Ilib/ -DNDEBUG main.cpp
In file included from /usr/include/c++/9/bits/move.h:55,
from /usr/include/c++/9/bits/nested_exception.h:40,
from /usr/include/c++/9/exception:144,
from /usr/include/c++/9/ios:39,
from /usr/include/c++/9/ostream:38,
from main.cpp:1:
/usr/include/c++/9/type_traits: In instantiation of ‘struct std::__is_trivially_copy_constructible_impl<std::reference_wrapper<std::basic_ostream<char> >, true>’:
/usr/include/c++/9/type_traits:1164:12: required from ‘struct std::is_trivially_copy_constructible<std::reference_wrapper<std::basic_ostream<char> > >’
/usr/include/c++/9/type_traits:2945:25: required from ‘constexpr const bool std::is_trivially_copy_constructible_v<std::reference_wrapper<std::basic_ostream<char> > >’
/usr/include/c++/9/optional:656:11: required from ‘class std::optional<std::reference_wrapper<std::basic_ostream<char> > >’
main.cpp:7:60: required from here
/usr/include/c++/9/type_traits:1157:12: error: invalid use of incomplete type ‘class std::reference_wrapper<std::basic_ostream<char> >’
1157 | struct __is_trivially_copy_constructible_impl<_Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/type_traits:2020:11: note: declaration of ‘class std::reference_wrapper<std::basic_ostream<char> >’
2020 | class reference_wrapper;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/type_traits: In instantiation of ‘constexpr const bool std::is_trivially_copy_constructible_v<std::reference_wrapper<std::basic_ostream<char> > >’:
/usr/include/c++/9/optional:656:11: required from ‘class std::optional<std::reference_wrapper<std::basic_ostream<char> > >’
main.cpp:7:60: required from here
/usr/include/c++/9/type_traits:2945:25: error: ‘value’ is not a member of ‘std::is_trivially_copy_constructible<std::reference_wrapper<std::basic_ostream<char> > >’
2945 | inline constexpr bool is_trivially_copy_constructible_v =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/type_traits: In instantiation of ‘struct std::__is_trivially_move_constructible_impl<std::reference_wrapper<std::basic_ostream<char> >, true>’:
/usr/include/c++/9/type_traits:1185:12: required from ‘struct std::is_trivially_move_constructible<std::reference_wrapper<std::basic_ostream<char> > >’
/usr/include/c++/9/type_traits:2948:25: required from ‘constexpr const bool std::is_trivially_move_constructible_v<std::reference_wrapper<std::basic_ostream<char> > >’
/usr/include/c++/9/optional:656:11: required from ‘class std::optional<std::reference_wrapper<std::basic_ostream<char> > >’
main.cpp:7:60: required from here
/usr/include/c++/9/type_traits:1178:12: error: invalid use of incomplete type ‘class std::reference_wrapper<std::basic_ostream<char> >’
1178 | struct __is_trivially_move_constructible_impl<_Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/type_traits:2020:11: note: declaration of ‘class std::reference_wrapper<std::basic_ostream<char> >’
2020 | class reference_wrapper;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/type_traits: In instantiation of ‘constexpr const bool std::is_trivially_move_constructible_v<std::reference_wrapper<std::basic_ostream<char> > >’:
/usr/include/c++/9/optional:656:11: required from ‘class std::optional<std::reference_wrapper<std::basic_ostream<char> > >’
main.cpp:7:60: required from here
/usr/include/c++/9/type_traits:2948:25: error: ‘value’ is not a member of ‘std::is_trivially_move_constructible<std::reference_wrapper<std::basic_ostream<char> > >’
2948 | inline constexpr bool is_trivially_move_constructible_v =
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Why can it compile in one place, but fail in another?
Where is the error?
Thanks!
#include <functional> to get the canonical definition of std::reference_wrapper.
As a general rule, cppreference includes the #include required for each std library template and type. So I just google it ("reference wrapper cppreference", misspellings ok) and look at the top of the page.
C++ std header files are free to include other std header files, types and template, or forward declare them. But if you want to reliably and portably use a template or type from std, you need to #include the correct header.
To diagnose this problem yourself from an error-stream, first look for the first error in it:
/usr/include/c++/9/type_traits:1157:12: error: invalid use of incomplete type ‘class std::reference_wrapper<std::basic_ostream<char> >’
It states std::reference_wrapper is incomplete. Then you can try to work out why this error is generated either from that one line, or you can follow the "breadcrumbs" of how you got there. Here, simply looking at that error line makes the solution relatively obvious; find a way to make std::reference_wrapper complete.
(I had seen this problem before, so I just assumed the std construct you didn't obviously #include a header for was missing, without having to look at your error messages.)
I would like to use the intersect_segments method of the Boost segment utils, which can be found here: http://www.boost.org/doc/libs/1_59_0/libs/polygon/doc/gtl_segment_concept.htm
I also have followed and implemented the code that maps the Point and Segment structs to the Boost.Polygon concepts: http://www.boost.org/doc/libs/1_59_0/libs/polygon/doc/voronoi_basic_tutorial.htm
However, when I include <boost/polygon/segment_utils.hpp> I get many errors during compiling:
In file included from /usr/include/boost/polygon/segment_utils.hpp:16:0,
from test.cpp:17:
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:17:49: error: expected template-name before '<' token
class line_intersection : public scanline_base<Unit> {
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:17:49: error: expected '{' before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:17:49: error: expected unqualified-id before '<' token
In file included from /usr/include/boost/polygon/segment_utils.hpp:16:0,
from test.cpp:17:
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:947:40: error: expected template-name before '<' token
class scanline : public scanline_base<Unit> {
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:947:40: error: expected '{' before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:947:40: error: expected unqualified-id before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1472:22: error: expected nested-name-specifier before 'scanline_base'
typedef typename scanline_base<Unit>::half_edge half_edge;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1472:22: error: expected ';' at end of member declaration
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1472:35: error: expected unqualified-id before '<' token
typedef typename scanline_base<Unit>::half_edge half_edge;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1475:48: error: 'half_edge' does not name a type
void operator()(result_type& result, const half_edge& edge, const key_type& left, const key_type& right) {
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp: In member function 'void boost::polygon::merge_output_functor<Unit>::operator()(result_type&, const int&, const key_type&, const key_type&)':
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1476:26: error: 'half_edge' was not declared in this scope
typename std::pair<half_edge, int> elem;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1476:40: error: template argument 1 is invalid
typename std::pair<half_edge, int> elem;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1476:42: error: 'elem' in namespace 'std' does not name a type
typename std::pair<half_edge, int> elem;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1477:7: error: 'elem' was not declared in this scope
elem.first = edge;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1479:15: error: request for member 'second' in 'edge', which is of non-class type 'const int'
if(edge.second < edge.first) elem.second *= -1;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1479:29: error: request for member 'first' in 'edge', which is of non-class type 'const int'
if(edge.second < edge.first) elem.second *= -1;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1480:10: error: 'boost::polygon::merge_output_functor<Unit>::scanline_base {aka int}' is not a template
if(scanline_base<Unit>::is_vertical(edge)) elem.second *= -1;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1480:10: error: 'scanline_base' is not a class, namespace, or enumeration
/usr/include/boost/polygon/detail/scan_arbitrary.hpp: At global scope:
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1491:46: error: expected template-name before '<' token
class property_merge : public scanline_base<Unit> {
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1491:46: error: expected '{' before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:1491:46: error: expected unqualified-id before '<' token
In file included from /usr/include/boost/polygon/segment_utils.hpp:16:0,
from test.cpp:17:
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2490:52: error: expected template-name before '<' token
class arbitrary_boolean_op : public scanline_base<Unit> {
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2490:52: error: expected '{' before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2490:52: error: expected unqualified-id before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp: In function 'bool boost::polygon::test_arbitrary_boolean_op(stream_type&)':
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2653:5: error: 'polygon_set_data' was not declared in this scope
polygon_set_data<Unit> psd;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2653:26: error: expected primary-expression before '>' token
polygon_set_data<Unit> psd;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2653:28: error: 'psd' was not declared in this scope
polygon_set_data<Unit> psd;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2657:26: error: expected primary-expression before '>' token
polygon_set_data<Unit> psd2;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2657:28: error: 'psd2' was not declared in this scope
polygon_set_data<Unit> psd2;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2660:17: error: 'polygon_data' was not declared in this scope
std::vector<polygon_data<Unit> > pv;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2660:34: error: template argument 1 is invalid
std::vector<polygon_data<Unit> > pv;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2660:34: error: template argument 2 is invalid
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2660:36: error: expected unqualified-id before '>' token
std::vector<polygon_data<Unit> > pv;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2661:5: error: 'pv' was not declared in this scope
pv.clear();
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2663:26: error: expected primary-expression before '>' token
polygon_set_data<Unit> psd3;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2663:28: error: 'psd3' was not declared in this scope
polygon_set_data<Unit> psd3;
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp: At global scope:
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2710:65: error: expected template-name before '<' token
class arbitrary_connectivity_extraction : public scanline_base<Unit> {
^
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2710:65: error: expected '{' before '<' token
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:2710:65: error: expected unqualified-id before '<' token
In file included from test.cpp:17:0:
/usr/include/boost/polygon/segment_utils.hpp: In function 'typename boost::enable_if<typename boost::polygon::gtl_and<typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<typename boost::polygon::geometry_concept<typename std::iterator_traits<_Iterator1>::value_type>::type>::type>::type, typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<typename boost::polygon::geometry_concept<GeometryType>::type>::type>::type>::type, void>::type boost::polygon::intersect_segments(std::vector<std::pair<long unsigned int, Segment> >&, SegmentIterator, SegmentIterator)':
/usr/include/boost/polygon/segment_utils.hpp:46:20: error: expected nested-name-specifier before 'scanline_base'
typedef typename scanline_base<Unit>::Point Point;
^
/usr/include/boost/polygon/segment_utils.hpp:46:33: error: expected initializer before '<' token
typedef typename scanline_base<Unit>::Point Point;
^
/usr/include/boost/polygon/segment_utils.hpp:47:20: error: expected nested-name-specifier before 'scanline_base'
typedef typename scanline_base<Unit>::half_edge half_edge;
^
/usr/include/boost/polygon/segment_utils.hpp:47:33: error: expected initializer before '<' token
typedef typename scanline_base<Unit>::half_edge half_edge;
^
/usr/include/boost/polygon/segment_utils.hpp:49:25: error: 'half_edge' was not declared in this scope
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:49:46: error: template argument 1 is invalid
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:49:48: error: template argument 1 is invalid
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:49:48: error: template argument 2 is invalid
/usr/include/boost/polygon/segment_utils.hpp:50:25: error: the value of 'half_edge' is not usable in a constant expression
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
^
/usr/include/boost/polygon/segment_utils.hpp:49:25: note: 'half_edge' was not declared 'constexpr'
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:50:46: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
^
/usr/include/boost/polygon/segment_utils.hpp:50:46: note: expected a type, got 'half_edge'
/usr/include/boost/polygon/segment_utils.hpp:50:48: error: template argument 1 is invalid
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
^
/usr/include/boost/polygon/segment_utils.hpp:50:48: error: template argument 2 is invalid
/usr/include/boost/polygon/segment_utils.hpp:52:14: error: request for member 'reserve' in 'half_edges', which is of non-class type 'int'
half_edges.reserve(std::distance(first, last));
^
/usr/include/boost/polygon/segment_utils.hpp:57:16: error: request for member 'push_back' in 'half_edges', which is of non-class type 'int'
half_edges.push_back(std::make_pair(half_edge(l, h), id_in++));
^
/usr/include/boost/polygon/segment_utils.hpp:59:18: error: request for member 'reserve' in 'half_edges_out', which is of non-class type 'int'
half_edges_out.reserve(half_edges.size());
^
/usr/include/boost/polygon/segment_utils.hpp:59:37: error: request for member 'size' in 'half_edges', which is of non-class type 'int'
half_edges_out.reserve(half_edges.size());
^
/usr/include/boost/polygon/segment_utils.hpp:61:18: error: request for member 'size' in 'half_edges', which is of non-class type 'int'
if (half_edges.size() != 0) {
^
/usr/include/boost/polygon/segment_utils.hpp:63:36: error: request for member 'begin' in 'half_edges', which is of non-class type 'int'
half_edges_out, half_edges.begin(), half_edges.end());
^
/usr/include/boost/polygon/segment_utils.hpp:63:56: error: request for member 'end' in 'half_edges', which is of non-class type 'int'
half_edges_out, half_edges.begin(), half_edges.end());
^
/usr/include/boost/polygon/segment_utils.hpp:66:49: error: request for member 'size' in 'half_edges_out', which is of non-class type 'int'
result.reserve(result.size() + half_edges_out.size());
^
/usr/include/boost/polygon/segment_utils.hpp:67:46: error: request for member 'size' in 'half_edges_out', which is of non-class type 'int'
for (std::size_t i = 0; i < half_edges_out.size(); ++i) {
^
/usr/include/boost/polygon/segment_utils.hpp:68:52: error: invalid types 'int[std::size_t {aka long unsigned int}]' for array subscript
std::size_t id = (std::size_t)(half_edges_out[i].second);
^
/usr/include/boost/polygon/segment_utils.hpp:69:31: error: invalid types 'int[std::size_t {aka long unsigned int}]' for array subscript
Point l = half_edges_out[i].first.first;
^
/usr/include/boost/polygon/segment_utils.hpp:70:31: error: invalid types 'int[std::size_t {aka long unsigned int}]' for array subscript
Point h = half_edges_out[i].first.second;
^
/usr/include/boost/polygon/segment_utils.hpp: In function 'typename boost::enable_if<typename boost::polygon::gtl_and<typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<typename boost::polygon::geometry_concept<typename std::iterator_traits<_Iterator1>::value_type>::type>::type>::type, typename boost::polygon::gtl_if<typename boost::polygon::is_segment_concept<typename boost::polygon::geometry_concept<typename SegmentContainer::value_type>::type>::type>::type>::type, void>::type boost::polygon::intersect_segments(SegmentContainer&, SegmentIterator, SegmentIterator)':
/usr/include/boost/polygon/segment_utils.hpp:101:20: error: expected nested-name-specifier before 'scanline_base'
typedef typename scanline_base<Unit>::Point Point;
^
/usr/include/boost/polygon/segment_utils.hpp:101:33: error: expected initializer before '<' token
typedef typename scanline_base<Unit>::Point Point;
^
/usr/include/boost/polygon/segment_utils.hpp:102:20: error: expected nested-name-specifier before 'scanline_base'
typedef typename scanline_base<Unit>::half_edge half_edge;
^
/usr/include/boost/polygon/segment_utils.hpp:102:33: error: expected initializer before '<' token
typedef typename scanline_base<Unit>::half_edge half_edge;
^
/usr/include/boost/polygon/segment_utils.hpp:104:25: error: 'half_edge' was not declared in this scope
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:104:46: error: template argument 1 is invalid
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:104:48: error: template argument 1 is invalid
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:104:48: error: template argument 2 is invalid
/usr/include/boost/polygon/segment_utils.hpp:105:25: error: the value of 'half_edge' is not usable in a constant expression
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
^
/usr/include/boost/polygon/segment_utils.hpp:104:25: note: 'half_edge' was not declared 'constexpr'
std::vector<std::pair<half_edge, segment_id> > half_edges;
^
/usr/include/boost/polygon/segment_utils.hpp:105:46: error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
^
/usr/include/boost/polygon/segment_utils.hpp:105:46: note: expected a type, got 'half_edge'
/usr/include/boost/polygon/segment_utils.hpp:105:48: error: template argument 1 is invalid
std::vector<std::pair<half_edge, segment_id> > half_edges_out;
^
/usr/include/boost/polygon/segment_utils.hpp:105:48: error: template argument 2 is invalid
/usr/include/boost/polygon/segment_utils.hpp:107:14: error: request for member 'reserve' in 'half_edges', which is of non-class type 'int'
half_edges.reserve(std::distance(first, last));
^
/usr/include/boost/polygon/segment_utils.hpp:112:16: error: request for member 'push_back' in 'half_edges', which is of non-class type 'int'
half_edges.push_back(std::make_pair(half_edge(l, h), id_in++));
^
/usr/include/boost/polygon/segment_utils.hpp:114:18: error: request for member 'reserve' in 'half_edges_out', which is of non-class type 'int'
half_edges_out.reserve(half_edges.size());
^
/usr/include/boost/polygon/segment_utils.hpp:114:37: error: request for member 'size' in 'half_edges', which is of non-class type 'int'
half_edges_out.reserve(half_edges.size());
^
/usr/include/boost/polygon/segment_utils.hpp:116:18: error: request for member 'size' in 'half_edges', which is of non-class type 'int'
if (half_edges.size() != 0) {
^
/usr/include/boost/polygon/segment_utils.hpp:118:36: error: request for member 'begin' in 'half_edges', which is of non-class type 'int'
half_edges_out, half_edges.begin(), half_edges.end());
^
/usr/include/boost/polygon/segment_utils.hpp:118:56: error: request for member 'end' in 'half_edges', which is of non-class type 'int'
half_edges_out, half_edges.begin(), half_edges.end());
^
/usr/include/boost/polygon/segment_utils.hpp:121:49: error: request for member 'size' in 'half_edges_out', which is of non-class type 'int'
result.reserve(result.size() + half_edges_out.size());
^
/usr/include/boost/polygon/segment_utils.hpp:122:46: error: request for member 'size' in 'half_edges_out', which is of non-class type 'int'
for (std::size_t i = 0; i < half_edges_out.size(); ++i) {
^
/usr/include/boost/polygon/segment_utils.hpp:123:31: error: invalid types 'int[std::size_t {aka long unsigned int}]' for array subscript
Point l = half_edges_out[i].first.first;
^
/usr/include/boost/polygon/segment_utils.hpp:124:31: error: invalid types 'int[std::size_t {aka long unsigned int}]' for array subscript
Point h = half_edges_out[i].first.second;
Could this mean that I need to implement the Unit concept as well? If so, how is that done?
Edit: My code is the same as this code: http://www.boost.org/doc/libs/1_61_0/libs/polygon/example/voronoi_basic_tutorial.cpp but then with #include <boost/polygon/segment_utils.hpp> added.
You just need to #include <boost/polygon/polygon.hpp> before including <boost/polygon/segment_utils.hpp>.
/usr/include/boost/polygon/detail/scan_arbitrary.hpp:17:49: error: expected template-name before '<' token
class line_intersection : public scanline_base<Unit> {
^
This error suggests you've defined line_intersection as a macro, because it's complaining about a < token where there isn't one in the source.
But since you haven't shown any code, we can't tell.
Edit after updated question:
This seems to be a a Boost bug, it can be reproduced with a file consisting of nothing but:
#include <boost/polygon/segment_utils.hpp>
I would like to create a search tree of a graph using dfs algorithm. I get compilation errors over and over my code is like that (the compilation error is so long that I do not paste it):
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
typedef graph_traits <Graph>::edge_descriptor Edge;
typedef graph_traits <Graph>::vertex_descriptor Vertex;
typedef pair<int, int> E;
vector<E> edges;
Graph g(edges.begin(), edges.end(), n);
vector<Vertex> p(n);
Vertex s = vertex(0,g);
breadth_first_search(g, s, visitor(record_predecessors(&p[0], on_tree_edge())));
Part of error:
instantiated from here
/usr/include/boost/graph/breadth_first_search.hpp:39:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘initialize_vertex’
/usr/include/boost/graph/breadth_first_search.hpp:40:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘discover_vertex’
/usr/include/boost/graph/breadth_first_search.hpp:41:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘examine_vertex’
/usr/include/boost/graph/breadth_first_search.hpp:42:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘examine_edge’
/usr/include/boost/graph/breadth_first_search.hpp:43:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘tree_edge’
/usr/include/boost/graph/breadth_first_search.hpp:44:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘non_tree_edge’
/usr/include/boost/graph/breadth_first_search.hpp:45:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘gray_target’
/usr/include/boost/graph/breadth_first_search.hpp:46:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘black_target’
/usr/include/boost/graph/breadth_first_search.hpp:47:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘finish_vertex’
make: *** [file] Error 1
breadth_first_search expects a BFSVisitor. record_predecessors returns an EventVisitor. You need to use make_bfs_visitor in order to make it work.
breadth_first_search(g, s, visitor(make_bfs_visitor(record_predecessors(&p[0], on_tree_edge()))));
I can't get my C++ program to compile. As you can see, I'm writing a Node.js addon. Here is the code (Eamorr_addon.cpp):
#include <iostream>
#include <v8.h>
#include <node.h>
#include <gmp.h>
#include "Definitions.h"
#include "Rk.h"
#include "tbb/concurrent_hash_map.h"
//#include <tbb/concurrent_vector.h>
using namespace std;
using namespace v8;
static Handle<Value> Echo(const Arguments& args) {
HandleScope scope;
if (args.Length() < 1) {
return ThrowException(Exception::TypeError(String::New("Bad argument")));
}
return scope.Close(args[0]);
}
extern "C" void init (Handle<Object> target)
{
HandleScope scope;
target->Set(String::New("hello"), String::New("world"));
NODE_SET_METHOD(target, "echo", Echo);
}
Everything works just fine when I remove the line #include "tbb/concurrent_hash_map.h".
Here is my gyp make file:
{
'targets': [
{
'target_name':'Eamorr_addon',
'sources':['src/Eamorr_addon.cpp'],
'include_dirs': ['/usr/include','/usr/local/include/'],
'cflags': ['-Wall','-fopenmp'],
'ldflags': ['-ltbb','-lgmp']
}
]
}
When I do node-gyp build, I get the following stream of errors which I can't get to the bottom of:
node-gyp build
info it worked if it ends with ok
spawn make [ 'BUILDTYPE=Release', '-f', 'Makefile.gyp' ]
CXX(target) out/Release/obj.target/DeDuplicator_addon/src/DeDuplicator_addon.o
In file included from /usr/include/tbb/concurrent_hash_map.h:51:0,
from src/DeDuplicator_addon.cpp:17:
/usr/include/tbb/atomic.h:218:31: error: expected nested-name-specifier before numeric constant
/usr/include/tbb/atomic.h:218:31: error: expected ‘>’ before numeric constant
/usr/include/tbb/atomic.h:224:33: error: expected ‘)’ before ‘addend’
/usr/include/tbb/atomic.h:224:40: error: ISO C++ forbids initialization of member ‘fetch_and_add’
/usr/include/tbb/atomic.h:224:40: error: making ‘fetch_and_add’ static
/usr/include/tbb/atomic.h:224:40: error: template declaration of ‘value_type tbb::internal::fetch_and_add’
In file included from /usr/include/tbb/concurrent_hash_map.h:51:0,
from src/DeDuplicator_addon.cpp:17:
/usr/include/tbb/atomic.h:228:31: error: expected identifier before numeric constant
/usr/include/tbb/atomic.h:228:31: error: expected ‘,’ or ‘...’ before numeric constant
/usr/include/tbb/atomic.h:251:28: error: expected identifier before numeric constant
/usr/include/tbb/atomic.h:251:28: error: expected ‘,’ or ‘...’ before numeric constant
/usr/include/tbb/atomic.h:255:28: error: expected identifier before numeric constant
/usr/include/tbb/atomic.h:255:28: error: expected ‘,’ or ‘...’ before numeric constant
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::fetch_and_add(int)’:
/usr/include/tbb/atomic.h:229:48: error: ‘addend’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::fetch_and_decrement()’:
/usr/include/tbb/atomic.h:243:33: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:243:33: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:243:33: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::fetch_and_decrement()’:
/usr/include/tbb/atomic.h:247:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:247:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:247:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator+=(int)’:
/usr/include/tbb/atomic.h:252:30: error: ‘addend’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator-=(int)’:
/usr/include/tbb/atomic.h:258:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:258:32: error: ‘addend’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator--()’:
/usr/include/tbb/atomic.h:266:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:266:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:266:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator--(int)’:
/usr/include/tbb/atomic.h:274:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:274:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:274:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:329:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long long int tbb::atomic<long long int>::operator=(long long int)’:
/usr/include/tbb/atomic.h:329:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long long int>& tbb::atomic<long long int>::operator=(const tbb::atomic<long long int>&)’:
/usr/include/tbb/atomic.h:329:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:330:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long long unsigned int tbb::atomic<long long unsigned int>::operator=(long long unsigned int)’:
/usr/include/tbb/atomic.h:330:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long long unsigned int>& tbb::atomic<long long unsigned int>::operator=(const tbb::atomic<long long unsigned int>&)’:
/usr/include/tbb/atomic.h:330:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:335:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long int tbb::atomic<long int>::operator=(long int)’:
/usr/include/tbb/atomic.h:335:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long int>& tbb::atomic<long int>::operator=(const tbb::atomic<long int>&)’:
/usr/include/tbb/atomic.h:335:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:336:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long unsigned int tbb::atomic<long unsigned int>::operator=(long unsigned int)’:
/usr/include/tbb/atomic.h:336:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long unsigned int>& tbb::atomic<long unsigned int>::operator=(const tbb::atomic<long unsigned int>&)’:
/usr/include/tbb/atomic.h:336:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:352:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘unsigned int tbb::atomic<unsigned int>::operator=(unsigned int)’:
/usr/include/tbb/atomic.h:352:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<unsigned int>& tbb::atomic<unsigned int>::operator=(const tbb::atomic<unsigned int>&)’:
/usr/include/tbb/atomic.h:352:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:353:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘int tbb::atomic<int>::operator=(int)’:
/usr/include/tbb/atomic.h:353:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<int>& tbb::atomic<int>::operator=(const tbb::atomic<int>&)’:
/usr/include/tbb/atomic.h:353:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:356:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘short unsigned int tbb::atomic<short unsigned int>::operator=(short unsigned int)’:
/usr/include/tbb/atomic.h:356:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<short unsigned int>& tbb::atomic<short unsigned int>::operator=(const tbb::atomic<short unsigned int>&)’:
/usr/include/tbb/atomic.h:356:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:357:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘short int tbb::atomic<short int>::operator=(short int)’:
/usr/include/tbb/atomic.h:357:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<short int>& tbb::atomic<short int>::operator=(const tbb::atomic<short int>&)’:
/usr/include/tbb/atomic.h:357:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:358:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘char tbb::atomic<char>::operator=(char)’:
/usr/include/tbb/atomic.h:358:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<char>& tbb::atomic<char>::operator=(const tbb::atomic<char>&)’:
/usr/include/tbb/atomic.h:358:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:359:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘signed char tbb::atomic<signed char>::operator=(signed char)’:
/usr/include/tbb/atomic.h:359:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<signed char>& tbb::atomic<signed char>::operator=(const tbb::atomic<signed char>&)’:
/usr/include/tbb/atomic.h:359:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:360:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘unsigned char tbb::atomic<unsigned char>::operator=(unsigned char)’:
/usr/include/tbb/atomic.h:360:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<unsigned char>& tbb::atomic<unsigned char>::operator=(const tbb::atomic<unsigned char>&)’:
/usr/include/tbb/atomic.h:360:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:363:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘wchar_t tbb::atomic<wchar_t>::operator=(wchar_t)’:
/usr/include/tbb/atomic.h:363:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<wchar_t>& tbb::atomic<wchar_t>::operator=(const tbb::atomic<wchar_t>&)’:
/usr/include/tbb/atomic.h:363:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:367:93: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
In file included from src/DeDuplicator_addon.cpp:17:0:
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::internal::hash_map_base::check_mask_race(tbb::interface4::internal::hash_map_base::hashcode_t, tbb::interface4::internal::hash_map_base::hashcode_t&) const’:
/usr/include/tbb/concurrent_hash_map.h:266:21: error: cannot convert ‘const tbb::atomic<long unsigned int>’ to ‘tbb::interface4::internal::hash_map_base::hashcode_t’ in assignment
/usr/include/tbb/concurrent_hash_map.h: In member function ‘tbb::interface4::internal::hash_map_base::segment_index_t tbb::interface4::internal::hash_map_base::insert_new_node(tbb::interface4::internal::hash_map_base::bucket*, tbb::interface4::internal::hash_map_base::node_base*, tbb::interface4::internal::hash_map_base::hashcode_t)’:
/usr/include/tbb/concurrent_hash_map.h:296:30: error: no match for ‘operator++’ in ‘++((tbb::interface4::internal::hash_map_base*)this)->tbb::interface4::internal::hash_map_base::my_size’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘void tbb::interface4::internal::hash_map_base::reserve(tbb::interface4::internal::hash_map_base::size_type)’:
/usr/include/tbb/concurrent_hash_map.h:316:32: error: no match for ‘operator!’ in ‘!((tbb::interface4::internal::hash_map_base*)this)->tbb::interface4::internal::hash_map_base::my_size’
/usr/include/tbb/concurrent_hash_map.h:316:32: note: candidate is: operator!(bool) <built-in>
/usr/include/tbb/concurrent_hash_map.h:317:32: error: cannot convert ‘tbb::atomic<long unsigned int>’ to ‘tbb::interface4::internal::hash_map_base::size_type’ in initialization
/usr/include/tbb/concurrent_hash_map.h:317:58: error: cannot convert ‘tbb::atomic<long unsigned int>’ to ‘tbb::interface4::internal::hash_map_base::size_type’ in assignment
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::empty() const’:
/usr/include/tbb/concurrent_hash_map.h:833:44: error: no match for ‘operator==’ in ‘((const tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_size == 0’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘tbb::interface4::concurrent_hash_map::size_type tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::bucket_count() const’:
/usr/include/tbb/concurrent_hash_map.h:839:53: error: no match for ‘operator+’ in ‘((const tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_mask + 1’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::exclude(tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::const_accessor&, bool)’:
/usr/include/tbb/concurrent_hash_map.h:1119:16: error: no ‘operator--(int)’ declared for postfix ‘--’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::erase(const Key&)’:
/usr/include/tbb/concurrent_hash_map.h:1160:16: error: no ‘operator--(int)’ declared for postfix ‘--’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘void tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::internal_copy(const tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>&)’:
/usr/include/tbb/concurrent_hash_map.h:1310:20: error: no match for ‘operator==’ in ‘((tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_mask == mask’
/usr/include/tbb/concurrent_hash_map.h:1323:19: error: no match for ‘operator++’ in ‘++((tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_size’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘void tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::internal_copy(I, I)’:
/usr/include/tbb/concurrent_hash_map.h:1340:11: error: no match for ‘operator++’ in ‘++((tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_size’
make: *** [out/Release/obj.target/DeDuplicator_addon/src/DeDuplicator_addon.o] Error 1
ERR! Error: `make` failed with exit code: 2
at Array.0 (/usr/local/lib/node_modules/node-gyp/lib/build.js:118:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
Can anyone suggest anything?
Edit:
Here is "Rk.h":
#ifndef RK_H_
#define RK_H_
#include <gmp.h>
#include "Definitions.h"
unsigned long int init_rkHash(char* str);
unsigned long int get_rkHash(unsigned long int prevHash,int prevAscii,int topAscii);
/*unsigned long int getFirstPrevHash(char* &buffer);*/
#endif /* RK_H_ */
and here is "Definitions.h":
#ifndef DEFINITIONS_H_
#define DEFINITIONS_H_
#define PORT 10002
#define CHUNKSIZE 512
#define PRIME 9223372036854775783
#define D 2
#endif /* DEFINITIONS_H_ */
#define macros are easy to use wrong. And giving them names like D calls for problems.
You defined D as
#define D 2
Now, if we look at atomic.h, we find e.g.
...
template<typename I, typename D, typename StepType>
struct atomic_impl_with_arithmetic: atomic_impl<I> {
...
value_type fetch_and_add( D addend ) {
...
template<memory_semantics M>
value_type fetch_and_decrement() {
return fetch_and_add<M>(__TBB_MINUS_ONE(D));
}
...
See the correlation?
What you get is:
...
template<typename I, typename 2, typename StepType>
struct atomic_impl_with_arithmetic: atomic_impl<I> {
...
value_type fetch_and_add( 2 addend ) {
...
template<memory_semantics M>
value_type fetch_and_decrement() {
return fetch_and_add<M>(__TBB_MINUS_ONE(2));
}
...
This is not valid C++.
Solution: Don't give macros a name that will probably clash. Rule of thumb: Every neat name clashes at least once in a lifetime and produce subtle and unreal error messages that might infect a poor maintainers (you?) nightly dreams with visions of indescribable demons. Therefore, only use macros if you absolutely must.
If D is supposed to be an integer (but who, except you, knows by that name?), you can do one of the following:
enum { D = 2 };
or
extern const int D; // in a header
const int D = 2; // in exactly one source file
or you may rethink your decision whether D needs to be constant at all and instead pass it as a parameter to your functions and classes.
Here is an excerpt from tbb/atomic.h
template<typename I, typename D, typename StepType>
struct atomic_impl_with_arithmetic: atomic_impl<I> {
public:
typedef I value_type;
template<memory_semantics M>
value_type fetch_and_add( D addend ) {
return value_type(internal::atomic_traits<sizeof(value_type),M>::fetch_and_add( &this->rep.value, addend*sizeof(StepType) ));
}
...
Now, if you substitute definition for D from Definitions.h you'll see what the issue is. In general it's a bad idea to make macro definitions with such names. If you've got too much code dependent on D you can fix the issue by undefining it befor including tbb headers, something like this:
#include "Definitions.h"
#include "Rk.h"
#pragma push_macro("D")
#undef D
#include "tbb/concurrent_hash_map.h"
#include <tbb/concurrent_vector.h>
#pragma pop_macro("D")