I've been working through the tutorials to Boost::Spirit and I'm trying to compile a super simple parser for adding numbers together, roughly based on the MiniXML example in the docs. I'm having trouble compiling in Xcode 5.1.1.
I've reduced it and found that even the definition of the grammar won't compile. Here is its current state:
Syntax.h:
#pragma once
#include <boost/spirit/include/qi.hpp>
namespace qi = boost::spirit::qi;
template <typename Iterator>
struct ExpressionGrammer : qi::grammar<Iterator, double(), ascii::space_type>
{
qi::rule<Iterator, double(), ascii::space_type> expression;
qi::rule<Iterator, double(), ascii::space_type> addsub;
ExpressionGrammer()
: ExpressionGrammer::base_type(expression)
{
using qi::lit;
addsub = (expression >> '+' >> expression)[_val = _1 + _2];
expression = (addsub | qi::double_)[_val = _1];
}
};
Syntax.cpp:
#include "Syntax.h"
// Nothing else
The errors are long and detailed but uninformative starting with a parse issue 'Declaration of anonymous struct must be a definition'. The first section I'll paste here. (Note the line numbers don't match as I've omitted commented out code)
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:9:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.h:12:
In file included from ../../../Cinder/boost/boost/spirit/include/qi.hpp:16:
In file included from ../../../Cinder/boost/boost/spirit/home/qi.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/action.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/action/action.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/meta_compiler.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/support/meta_compiler.hpp:19:
In file included from ../../../Cinder/boost/boost/proto/proto.hpp:12:
In file included from ../../../Cinder/boost/boost/proto/core.hpp:21:
In file included from ../../../Cinder/boost/boost/proto/fusion.hpp:22:
In file included from ../../../Cinder/boost/boost/fusion/include/intrinsic.hpp:10:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/back.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/end.hpp:17:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp:10:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp:14:
../../../Cinder/boost/boost/fusion/container/list/cons_fwd.hpp:13:5: error: declaration of anonymous struct must be a definition
struct nil;
^
../../../Cinder/boost/boost/fusion/container/list/cons_fwd.hpp:13:5: warning: declaration does not declare anything [-Wmissing-declarations]
struct nil;
^~~~~~
../../../Cinder/boost/boost/fusion/container/list/cons_fwd.hpp:15:44: error: expected a type
template <typename Car, typename Cdr = nil>
^
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:1:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/SpiritTest_Prefix.pch:8:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/AppBasic.h:27:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/App.h:27:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/Renderer.h:32:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:68:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/MacTypes.h:90:17: note: expanded from macro 'nil'
#define nil NULL
^
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:1:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/SpiritTest_Prefix.pch:6:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/Cinder.h:92:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/chrono:280:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:203:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstddef:44:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include/stddef.h:72:18: note: expanded from macro 'NULL'
# define NULL __null
^
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:9:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.h:12:
In file included from ../../../Cinder/boost/boost/spirit/include/qi.hpp:16:
In file included from ../../../Cinder/boost/boost/spirit/home/qi.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/action.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/action/action.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/meta_compiler.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/support/meta_compiler.hpp:19:
In file included from ../../../Cinder/boost/boost/proto/proto.hpp:12:
In file included from ../../../Cinder/boost/boost/proto/core.hpp:21:
In file included from ../../../Cinder/boost/boost/proto/fusion.hpp:22:
In file included from ../../../Cinder/boost/boost/fusion/include/intrinsic.hpp:10:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/back.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/end.hpp:17:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp:10:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/detail/segmented_end_impl.hpp:14:
../../../Cinder/boost/boost/fusion/container/list/cons_fwd.hpp:15:44: error: expected ',' or '>' in template-parameter-list
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:1:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/SpiritTest_Prefix.pch:8:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/AppBasic.h:27:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/App.h:27:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/Renderer.h:32:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:68:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/MacTypes.h:90:17: note: expanded from macro 'nil'
#define nil NULL
^
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:1:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/SpiritTest_Prefix.pch:6:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/Cinder.h:92:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/chrono:280:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:203:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/cstddef:44:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include/stddef.h:72:18: note: expanded from macro 'NULL'
# define NULL __null
^
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:9:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.h:12:
In file included from ../../../Cinder/boost/boost/spirit/include/qi.hpp:16:
In file included from ../../../Cinder/boost/boost/spirit/home/qi.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/action.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/action/action.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/qi/meta_compiler.hpp:14:
In file included from ../../../Cinder/boost/boost/spirit/home/support/meta_compiler.hpp:19:
In file included from ../../../Cinder/boost/boost/proto/proto.hpp:12:
In file included from ../../../Cinder/boost/boost/proto/core.hpp:21:
In file included from ../../../Cinder/boost/boost/proto/fusion.hpp:22:
In file included from ../../../Cinder/boost/boost/fusion/include/intrinsic.hpp:10:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/back.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/end.hpp:17:
In file included from ../../../Cinder/boost/boost/fusion/sequence/intrinsic/detail/segmented_end.hpp:11:
In file included from ../../../Cinder/boost/boost/fusion/iterator/segmented_iterator.hpp:10:
In file included from ../../../Cinder/boost/boost/fusion/iterator/detail/segmented_iterator.hpp:18:
../../../Cinder/boost/boost/fusion/iterator/detail/segmented_equal_to.hpp:16:5: error: declaration of anonymous struct must be a definition
struct nil;
^
../../../Cinder/boost/boost/fusion/iterator/detail/segmented_equal_to.hpp:16:5: warning: declaration does not declare anything [-Wmissing-declarations]
struct nil;
^~~~~~
../../../Cinder/boost/boost/fusion/iterator/detail/segmented_equal_to.hpp:35:43: error: expected unqualified-id
struct segmented_equal_to<fusion::nil, fusion::nil>
^
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/Syntax.cpp:1:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/SpiritTest_Prefix.pch:8:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/AppBasic.h:27:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/App.h:27:
In file included from /Users/timmb/Documents/Programming/demos/SpiritTest/xcode/../../../Cinder/include/cinder/app/Renderer.h:32:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:38:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:68:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/MacTypes.h:90:17: note: expanded from macro 'nil'
#define nil NULL
Can anyone spot what I've done wrong?
(Incidentally, I'm using Boost 1.53 due to an external library requirement.)
It seems you are missing some
includes (for the semantic actions)
#include <boost/spirit/include/phoenix.hpp>
namespace aliases
namespace ascii = boost::spirit::ascii;
using statements / qualifiers
using qi::_val;
using qi::_1;
using qi::_2;
See it Live On Coliru
Note also that the [_val = _1] is redundant (automatic attribute propagation achieves the same).
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
template <typename Iterator>
struct ExpressionGrammer : qi::grammar<Iterator, double(), ascii::space_type>
{
qi::rule<Iterator, double(), ascii::space_type> expression;
qi::rule<Iterator, double(), ascii::space_type> addsub;
ExpressionGrammer()
: ExpressionGrammer::base_type(expression)
{
using qi::lit;
using qi::_val;
using qi::_1;
using qi::_2;
addsub = (expression >> '+' >> expression)[_val = _1 + _2];
expression = (addsub | qi::double_)[_val = _1];
}
};
int main()
{
ExpressionGrammer<char*> g;
}
Related
I have made the 'mistake' to update few things in my MacOS Monterey Intel-based and now I cannot source any cpp file as I used to do with Rcpp.
I tried to understand how others have resolved similar issues, but my problem seem to still remain.
Below you can find the error message, which perhaps may help to point me out to the possible solution:
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:30:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:642:26: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:642:60: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:643:18: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:643:50: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:648:17: error: no template named 'numeric_limits'
static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:651:25: error: no template named 'numeric_limits'
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:651:58: error: no template named 'numeric_limits'
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:661:16: error: no template named 'numeric_limits'
using _Lim = numeric_limits<_IntT>;
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim'
return _Lim::max();
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim'
} else if (__r <= _Lim::lowest()) {
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim'
return _Lim::min();
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:30:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:153:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/unordered_map:437:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__hash_table:16:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/algorithm:653:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/functional:490:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__algorithm/search.h:15:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__iterator/iterator_traits.h:14:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__iterator/incrementable_traits.h:14:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/concepts:134:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__functional_base:22:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/exception:83:
/usr/local/opt/llvm/bin/../include/c++/v1/cstdlib:138:9: error: target of using declaration conflicts with declaration already in scope
using ::abs _LIBCPP_USING_IF_EXISTS;
^
/usr/local/include/stdlib.h:132:6: note: target of using declaration
int abs(int) __pure2;
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: conflicting declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:853:1: error: declaration conflicts with target of using declaration already in scope
abs(const complex<_Tp>& __c)
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: target of using declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:9: note: using declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:910:16: error: reference to unresolved using declaration
return abs(__c.real());
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:912:16: error: reference to unresolved using declaration
return abs(__c.imag());
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:969:16: error: reference to unresolved using declaration
__re = abs(__re);
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:1022:29: error: reference to unresolved using declaration
return complex<_Tp>(log(abs(__x)), arg(__x));
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:1049:23: error: reference to unresolved using declaration
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:1174:33: error: reference to unresolved using declaration
return complex<_Tp>(abs(__x.real()), __x.imag());
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file1851d7b0603f9.o] Error 1
/usr/local/opt/llvm/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include" -I"/private/var/folders/pq/hxwd9my563q_qpy4rbrlgkmw0000gn/T/RtmpYPQ7or/sourceCpp-x86_64-apple-darwin17.0-1.0.8.3" -I/usr/local/include -fPIC -I/usr/local/opt/llvm/include -c file1851d7b0603f9.cpp -o file1851d7b0603f9.o
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
System information
Have I written custom code: Custom project
OS Platform and Distribution: macOS Sierra (10.12.6)
TensorFlow installed from: Source
TensorFlow version: Git tagged at 1.3 and master at d27ed9c
Python version: Python 2.7.13 :: Anaconda 4.4.0
Bazel version: 0.5.3_1-homebrew
Protobuf version: 3.3.2-homebrew
CUDA/cuDNN version: N/A
GPU model and memory: N/A
Exact command to reproduce:
Problem description
I compiled TensorFlow source code for Python & C++ API bindings following the steps shown in http://www.blitzblit.com/2017/06/11/creating-tensorflow-c-headers-and-libraries/ (We have to take into account that this tutorial is not updated). After compiling the TF source code I include the TF library in the C++ project:
#include <tensorflow/core/public/session.h>
Finally, I compile the C++ project (Until here everything seems fine). Then, when I try to launch the C++ code I get the following message:
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/arcadillanzacarmona/Desktop/FaceSDK/ cmake-build-debug --target FaceSDK -- -j 2
[ 96%] Built target dlib
[ 96%] Building CXX object CMakeFiles/FaceSDK.dir/main.cpp.o
clang: warning: -lcurl: 'linker' input unused [-Wunused-command-line-argument]
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:328:33: error: expected a qualified name after 'typename'
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:328:33: error: expected ',' or '>' in template-parameter-list
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:864:59: error: template argument for non-type template parameter must be an expression
typedef internal::RepeatedPtrOverPtrsIterator<Element*, void*>
^~~~~
/usr/local/include/google/protobuf/repeated_field.h:328:33: note: template parameter is declared here
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:867:55: error: template argument for non-type template parameter must be an expression
const void* const>
^~~~~
/usr/local/include/google/protobuf/repeated_field.h:328:33: note: template parameter is declared here
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2258:38: error: expected a qualified name after 'typename'
template <typename Element, typename VoidPtr>
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2258:38: error: expected ',' or '>' in template-parameter-list
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2262:48: error: template argument for non-type template parameter must be an expression
typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;
^~~~~~~
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^~~~~~
/usr/local/include/google/protobuf/repeated_field.h:2258:38: note: template parameter is declared here
template <typename Element, typename VoidPtr>
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2289:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator==(const iterator& x) const { return it_ == x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2290:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator!=(const iterator& x) const { return it_ != x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2293:59: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator<(const iterator& x) const { return it_ < x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2294:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator<=(const iterator& x) const { return it_ <= x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2295:59: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator>(const iterator& x) const { return it_ > x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2296:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator>=(const iterator& x) const { return it_ >= x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2324:70: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
difference_type operator-(const iterator& x) const { return it_ - x.it_; }
~^~~~
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:24:
In file included from /usr/local/include/tensorflow/core/framework/tensor.h:21:
In file included from /usr/local/include/tensorflow/core/framework/allocator.h:26:
In file included from /usr/local/include/tensorflow/core/framework/variant.h:30:
In file included from /usr/local/include/tensorflow/core/platform/mutex.h:31:
/usr/local/include/tensorflow/core/platform/default/mutex.h:25:10: fatal error: 'nsync_cv.h' file not found
#include "nsync_cv.h"
^
15 errors generated.
gmake[3]: *** [CMakeFiles/FaceSDK.dir/build.make:63: CMakeFiles/FaceSDK.dir/main.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/FaceSDK.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/FaceSDK.dir/rule] Error 2
gmake: *** [Makefile:118: FaceSDK] Error 2
Can anyone help me? Seems that the main problem is in the google/protobuf.
The problem is that gif_lib.h and that protobuf header file are incompatible. More specifically, the problem is that gif_lib.h uses the preprocessor to define a macro called VoidPtr, and then the protobuf header uses VoidPtr as an identifier. The fault firmly lays with gif_lib, not protobuf! Preprocessor macros, by convention, are usually uppercase, should include the library name, and should be avoided entirely if possible (in this case, wouldn't a typedef have done?).
Here are some possible workarounds:
Include the protobuf header (or something that includes it, like a TensorFlow header) before the gif_lib.h one (or, again, something that includes it).
After including gif_lib.h, write #undef VoidPtr on a separate line (but this might cause other mysterious problems, depending on how gif_lib.h is implemented.
Do not #include those both of those two headers from any one of your files; hide them behind your own interfaces.
File a bug with whoever wrote gif_lib and get them to stop using the proprocessor in such a dangerous way.
Use a better designed library in place of gif_lib.
I had the similar issue which is solved by changing compiler and using a different version of C++(i.e. from clang to g++-5, g++-7, etc.). I suggest that you can try to solve it in this way. Sorry for not able to give a direct solution.
For the error about nsync_cv, alc1218's solution on this post may help, which is changing the file mutex.h as follows:
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
#define TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
// IWYU pragma: private, include "third_party/tensorflow/core/platform/mutex.h"
// IWYU pragma: friend third_party/tensorflow/core/platform/mutex.h
#include <chrono>
#include <condition_variable>
#include <mutex>
#include "tensorflow/core/platform/thread_annotations.h"
namespace tensorflow {
#undef mutex_lock
enum LinkerInitialized { LINKER_INITIALIZED };
// A class that wraps around the std::mutex implementation, only adding an
// additional LinkerInitialized constructor interface.
class LOCKABLE mutex : public std::mutex {
public:
mutex() {}
// The default implementation of std::mutex is safe to use after the linker
// initializations
explicit mutex(LinkerInitialized x) {}
void lock() ACQUIRE() { std::mutex::lock(); }
bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return std::mutex::try_lock();
};
void unlock() RELEASE() { std::mutex::unlock(); }
};
class SCOPED_LOCKABLE mutex_lock : public std::unique_lock<std::mutex> {
public:
mutex_lock(class mutex& m) ACQUIRE(m) : std::unique_lock<std::mutex>(m) {}
mutex_lock(class mutex& m, std::try_to_lock_t t) ACQUIRE(m)
: std::unique_lock<std::mutex>(m, t) {}
mutex_lock(mutex_lock&& ml) noexcept
: std::unique_lock<std::mutex>(std::move(ml)) {}
~mutex_lock() RELEASE() {}
};
// Catch bug where variable name is omitted, e.g. mutex_lock (mu);
#define mutex_lock(x) static_assert(0, "mutex_lock_decl_missing_var_name");
using std::condition_variable;
inline ConditionResult WaitForMilliseconds(mutex_lock* mu,
condition_variable* cv, int64 ms) {
std::cv_status s = cv->wait_for(*mu, std::chrono::milliseconds(ms));
return (s == std::cv_status::timeout) ? kCond_Timeout : kCond_MaybeNotified;
}
} // namespace tensorflow
#endif // TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
or simply find where your "nsync_cv" is and include the whole path.
I wrote the following code after using "gedit take_input.cpp":
#include <iostream>
int main()
{
cout<<"please enter your name (followed by 'enter')\n";
string file;
cin >> file;
cout<<"hello" << file << " ! welcome to ilinux, where innovation is a promise\n";
}
However, when I used "g++" to convert my human-readable code into object code (writing g++ take_input.cpp -o take_input), the terminal returns with a result similar to this:
take_input.cpp: In function ‘int main()’:
take_input.cpp:5:1: error: ‘cout’ was not declared in this scope
cout<<"please enter your name (followed by 'enter')\n";
^
take_input.cpp:5:1: note: suggested alternative:
In file included from take_input.cpp:1:0:
/usr/include/c++/4.9/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^
take_input.cpp:7:1: error: ‘string’ was not declared in this scope
string file;
^
take_input.cpp:7:1: note: suggested alternative:
In file included from /usr/include/c++/4.9/iosfwd:39:0,
from /usr/include/c++/4.9/ios:38,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from take_input.cpp:1:
/usr/include/c++/4.9/bits/stringfwd.h:62:33: note: ‘std::string’
typedef basic_string<char> string;
^
take_input.cpp:9:1: error: ‘cin’ was not declared in this scope
cin >> file;
^ ^
take_input.cpp:9:8: error: ‘file’ was not declared in this scope
cin >> file;
take_input.cpp:9:1: note: suggested alternative:
In file included from take_input.cpp:1:0:
/usr/include/c++/4.9/iostream:60:18: note: ‘std::cin’
extern istream cin; /// Linked to standard input
^
take_input.cpp:9:8: error: ‘file’ was not declared in this scope
cin >> file;
^
Could you tell me what the reason is?
The errors that you are getting are because the cout is not in the global namespace rather it is in std namespace.
Well instead of writing
using namespace std;
after #include <iostream> try using:
using std::cout;
since using first option is a bad practice. You can refer to Why is using namespace std is a bad practice.
For benefits of using using std::cout refer Using std namespace
Also you can use std::cout everywhere if you don't want to use using std::cout.
Just read the error messages that you compiler gave you. The problem is that
‘cout’ was not declared in this scope
And the "suggested alternative" is std::cout. Same goes for string vs. std::string.
Note that generally, things belonging to the standard library need to be qualified with std:: to be found.
You also need to #include <string> to use std::string btw.
The compiler gives you the answer on line 7: Since you're not using the std namespace, you have to prepend std:: to your cout and cin calls.
Just add
using namespace std;
after #include <iostream>
Try this out.
For some odd reason I recieve unknown type name for a typedef void variable located in a header file. Naturally i searched around the net and while it can be noted that I found similar issues it should also be noted that I am not using an IDE only Vim and Clang and don't have precompiled headers. In a separate test for the ctrie_int header, everything compiles but when I extend the implementation adding its header to the implementation file of another header I get the weird error seen below. I'm sure its a simple issue but i'm not sure what it is, any suggestions?
clang++ -Wall -Wextra -g -std=c++11 lzwtest.cpp -o lzwtest dict;
Project Compilation
.
.
.
.
.
Compiling CPP file lzwtest.cpp ...
In file included from lzwtest.cpp:2:
In file included from ./LZW.h:23:
In file included from ./ctrie_int.h:36:
./ctrie_int.ii:7:1: error: unknown type name 'Trie_Int'
Trie_Int * newTrie_Int(int defVal){return new Trie<int>(defVal);}
^
./ctrie_int.ii:7:43: error: cannot initialize return object of type 'int *' with an rvalue of type 'Trie<int> *'
Trie_Int * newTrie_Int(int defVal){return new Trie<int>(defVal);}
^~~~~~~~~~~~~~~~~~~~~
./ctrie_int.ii:9:21: error: unknown type name 'Trie_Int'
void deleteTrie_Int(Trie_Int * trie){delete ((Trie<int> *)trie);}
^
./ctrie_int.ii:11:19: error: unknown type name 'Trie_Int'
int Trie_Int_size(Trie_Int * t){return ((Trie<int> *)t)->size();}
^
./ctrie_int.ii:13:30: error: unknown type name 'Trie_Int'
int Trie_Int_getDefaultValue(Trie_Int * t){return ((Trie<int> *)t)->getDefaultValue();}
^
./ctrie_int.ii:15:23: error: unknown type name 'Trie_Int'
int Trie_Int_contains(Trie_Int * t,const char * key){return ((Trie<int> *)t)->contains(key); }
^
./ctrie_int.ii:17:18: error: unknown type name 'Trie_Int'
int Trie_Int_get(Trie_Int * t,char * key){return ((Trie<int> *)t)->get(key); }
^
./ctrie_int.ii:19:19: error: unknown type name 'Trie_Int'
void Trie_Int_put(Trie_Int * t,char * s,int val){ ((Trie<int> *)t)->put(s,val);}
^
./ctrie_int.ii:21:37: error: unknown type name 'Trie_Int'
const char * Trie_Int_longestPrefix(Trie_Int * t,char * s){return ((Trie<int> *)t)->longestPrefix(s).c_str();}
^
./ctrie_int.ii:23:23: error: unknown type name 'Trie_Int'
int Trie_Int_compress(Trie_Int * t){return ((Trie<int> *)t)->compress();}
^
10 errors generated.
Below is the header for the file being included
ctrie_int.h
#ifndef COM_WORDGAME_UTILITY_CTRIE_H
#define COM_WORDGAME_UTILITY_CTRIE_H
#ifdef __cplusplus
extern "C"{ //this is used to identify following code as C specific code which will enforce C style name mangling
#endif
//Declare a new void Type To Emulate C class
typedef void Trie_Int;
...Removed in attempt to shorten Question
#ifdef __cplusplus
}
#endif
#endif
This file uses the previous but even simple code or just the inclusion of the header file of the last causes the error described in the beginning
#ifndef COM_WORDGAME_UTILITY_CTRIE_H
#define COM_WORDGAME_UTILITY_CTRIE_H
#ifdef __cplusplus
extern "C"{ //this is used to identify following code as C specific code which will enforce C style name mangling
#endif
void compress(char src[],char dst[]);
void decompress(char src[],char dst[]);
#ifdef __cplusplus
}
#endif
#endif
//BELOW CODE WILL BE ADDED IN ANOTHER FILE
#include <stdio.h>
#include <stdlib.h>
#include "ctrie_int.h" // This causes an issue cannot find Trie_Int the functions return an odd message describing the Trie_Int was defered to an actual pointer integer
for clarity the first few lines of ctrie.ii looks like this
//#include "ctrie_int.h" //Should not be included would create cycle since ctrie_int.h declares it at the final line
#include "Trie.hpp" //C++ code
//THIS HAS TO BE COMPILED WITH C++ COMPILER TO BE COMPILED PROPERLY ANYWAY GAURDS UNEEDED
extern "C"{
//Create new Trie_Int Object
Trie_Int * newTrie_Int(int defVal){return new Trie<int>(defVal);}
....Removed In Attempt to shorten question
}
The clue is in the first stages of the error message:
Compiling CPP file lzwtest.cpp ...
In file included from lzwtest.cpp:2:
In file included from ./LZW.h:23:
In file included from ./ctrie_int.h:36: <<< Here
./ctrie_int.ii:7:1: error: unknown type name 'Trie_Int'
It appears that the file ctrie_int.ii is being included from your header before Trie_Int has been defined.
I am trying to modify a C++ program by including POCO to be able to do a HTTP request and receive a result. Basically, I just need within another C++ program to give a username and password and get a plain "OK" or "ERROR" response.
I am not familiar with C++ at all (use Java mainly). I build the POCO project and installed it without any problems, but when I add it to the project I get a while pile of compiler errors when building:
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
In file included from /usr/local/include/Poco/Timespan.h:44:
/usr/local/include/Poco/Timestamp.h:50:1: error: declaration of anonymous class must be a definition
class Foundation_API Timestamp
^
/usr/local/include/Poco/Timestamp.h:149:24: error: expected identifier
inline bool Timestamp::operator == (const Timestamp& ts) const
^
/usr/local/include/Poco/Timestamp.h:149:13: error: declaration of anonymous struct must be a definition
inline bool Timestamp::operator == (const Timestamp& ts) const
^
../crtmpserver/sources/common/include/platform/osx/osxplatform.h:109:19: note: expanded from macro 'Timestamp'
#define Timestamp struct tm
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
In file included from /usr/local/include/Poco/Timespan.h:44:
/usr/local/include/Poco/Timestamp.h:262:1: error: expected unqualified-id
} // namespace Poco
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
/usr/local/include/Poco/Timespan.h:54:21: error: no struct named 'TimeDiff' in 'tm'
typedef Timestamp::TimeDiff TimeDiff;
~~~~~~~~~~~^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:47:
/usr/local/include/Poco/Any.h:123:46: error: cannot use typeid with -fno-rtti
return _content ? _content->type() : typeid(void);
^
/usr/local/include/Poco/Any.h:149:20: error: cannot use typeid with -fno-rtti
return typeid(ValueType);
^
/usr/local/include/Poco/Any.h:180:42: error: cannot use typeid with -fno-rtti
return operand && operand->type() == typeid(ValueType)
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
/usr/local/include/Poco/Net/HTTPClientSession.h:291:8: error: expected member name or ';' after declaration specifiers
Poco::Timestamp _lastRequest;
~~~~ ^
../crtmpserver/sources/common/include/platform/osx/osxplatform.h:109:19: note: expanded from macro 'Timestamp'
#define Timestamp struct tm
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:94:10: error: expected expression
form.add(<D2>entry1<D3>, <D2>value1<D3>);
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:97:25: error: variable has incomplete type 'Poco::Net::HTTPResponse'
Poco::Net::HTTPResponse response;
^
/usr/local/include/Poco/Net/HTTPClientSession.h:55:7: note: forward declaration of 'Poco::Net::HTTPResponse'
class HTTPResponse;
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:99:41: error: no member named 'cout' in namespace 'std'; did you mean 'count'?
Poco::StreamCopier::copyStream(rs, std::cout);
~~~~~^~~~
count
/usr/include/c++/4.2.1/bits/stl_algo.h:424:5: note: 'count' declared here
count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:99:36: error: address of overloaded function 'count' does not match required type 'std::basic_ostream<char>'
Poco::StreamCopier::copyStream(rs, std::cout);
^~~~~~~~~
/usr/include/c++/4.2.1/bits/stl_algo.h:424:5: note: candidate function
count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
^
/usr/local/include/Poco/StreamCopier.h:57:73: note: passing argument to parameter 'ostr' here
static std::streamsize copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
^
13 errors generated.
make[2]: *** [applications/idomsconnector/CMakeFiles/idomsconnector.dir/Users/[...]/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp.o] Error 1
make[1]: *** [applications/idomsconnector/CMakeFiles/idomsconnector.dir/all] Error 2
make: *** [all] Error 2
build failed
My code fragment is as follows:
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/StreamCopier.h>
string RTMPAppProtocolHandler::GetAuthPassword(string user) {
INFO("Testing auth: %s", STR(user));
Poco::Net::HTTPClientSession s("www.somehost.com");
//s.setProxy("localhost", srv.port());
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, "/large");
Poco::Net::HTMLForm form;
form.add(“entry1”, “value1”);
form.prepareSubmit(request);
s.sendRequest(request);
Poco::Net::HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
Poco::StreamCopier::copyStream(rs, std::cout);
return user;
}
Am I doing something stupid? It is only this little interaction with a HTTP server which I need to modify, so I am just looking for a very simple solution but find it hard to find something that works easy (mainly because I am not familiar with C++ though)