Cannot source cpp file after updating xcode and Rstudio in MacOS Monterey - c++

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.

Related

minGW error on locale library

I changed from using Dev-c++ to visual studio code. But it seems i can't compile the minGW because of this bug, i got this bug if i use sublime too. Please help me with this.
*sorry for my bad english
C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\locale.h:36:13: warning: #pragma system_header ignored outside include file
#pragma GCC system_header
^~~~~~~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:41:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\localefwd.h:40,
from C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\locale.h:38:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\clocale:53:11: error: '::lconv' has not been declared
using ::lconv;
^~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\clocale:54:11: error: '::setlocale' has not been declared
using ::setlocale;
^~~~~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\clocale:55:11: error: '::localeconv' has not been declared
using ::localeconv;
^~~~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\localefwd.h:40:0,
from C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\locale.h:38:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h: In function 'int std::__convert_from_v(int* const&, char*, int, const char*, ...)':
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:60:19: error: 'setlocale' is not a member of 'std'
char* __old = std::setlocale(LC_NUMERIC, 0);
^~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:60:34: error: 'LC_NUMERIC' was not declared in this scope
char* __old = std::setlocale(LC_NUMERIC, 0);
^~~~~~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:67:2: error: 'setlocale' is not a member of 'std'
std::setlocale(LC_NUMERIC, "C");
^~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:83:2: error: 'setlocale' is not a member of 'std'
std::setlocale(LC_NUMERIC, __sav);
^~~

How to compile a program from .cpp files and a makefile

I recently downloaded a program. A patient specific survival prediction CLI, http://pssp.srv.ualberta.ca/
The readme included states:
"1 Compilation
The code should compile on Linux without any modification. To compile, just type ’make’. There should
be 2 executables after compilation, mtlr train and mtlr test."
I download an extracted the folder to my location, when I go into the directory and type make I get:
x#x-laptop:/pssp_source$ make
g++ -c -O3 DenseVector.cpp -o DenseVector.o
In file included from DenseVector.cpp:1:0:
DenseVector.h:9:2: error: ‘size_t’ does not name a type
size_t m_dim;
^
DenseVector.h:18:21: error: expected ‘)’ before ‘n’
DenseVector(size_t n);
^
DenseVector.h:26:33: error: ‘size_t’ does not name a type
double const& operator[](const size_t i) const
^
DenseVector.h:26:40: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive]
double const& operator[](const size_t i) const
^
DenseVector.h:31:27: error: ‘size_t’ does not name a type
double& operator[](const size_t i)
^
DenseVector.h:31:34: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive]
double& operator[](const size_t i)
^
DenseVector.h:38:2: error: ‘size_t’ does not name a type
size_t dim() const
^
DenseVector.h: In member function ‘void DenseVector::push_back(double)’:
DenseVector.h:23:3: error: ‘m_dim’ was not declared in this scope
m_dim++;
^
DenseVector.cpp: At global scope:
DenseVector.cpp:6:1: error: prototype for ‘DenseVector::DenseVector(size_t)’ does not match any in class ‘DenseVector’
DenseVector::DenseVector(size_t n): m_dim(n)
^
In file included from DenseVector.cpp:1:0:
DenseVector.h:5:7: error: candidates are: DenseVector::DenseVector(const DenseVector&)
class DenseVector
^
DenseVector.h:12:2: error: DenseVector::DenseVector()
DenseVector(void);
^
DenseVector.cpp: In constructor ‘DenseVector::DenseVector()’:
DenseVector.cpp:16:2: error: class ‘DenseVector’ does not have any field named ‘m_dim’
:m_dim(0)
^
DenseVector.cpp: In member function ‘void DenseVector::clear()’:
DenseVector.cpp:27:22: error: ‘m_dim’ was not declared in this scope
for (size_t i=0; i<m_dim; i++)
^
In file included from /usr/include/c++/4.8/cassert:43:0,
from DenseVector.cpp:3:
DenseVector.cpp: In function ‘double sprod_nn(const DenseVector&, const DenseVector&)’:
DenseVector.cpp:37:11: error: ‘const class DenseVector’ has no member named ‘dim’
assert(a.dim() == b.dim());
^
DenseVector.cpp:37:22: error: ‘const class DenseVector’ has no member named ‘dim’
assert(a.dim() == b.dim());
^
DenseVector.cpp:38:15: error: ‘const class DenseVector’ has no member named ‘dim’
size_t n = a.dim();
^
In file included from /usr/include/c++/4.8/cassert:43:0,
from DenseVector.cpp:3:
DenseVector.cpp: In function ‘void multadd_nn(DenseVector&, const DenseVector&, double)’:
DenseVector.cpp:49:11: error: ‘class DenseVector’ has no member named ‘dim’
assert(w.dim()==a.dim());
^
DenseVector.cpp:49:20: error: ‘const class DenseVector’ has no member named ‘dim’
assert(w.dim()==a.dim());
^
DenseVector.cpp:50:15: error: ‘class DenseVector’ has no member named ‘dim’
size_t n = w.dim();
^
DenseVector.cpp: In function ‘void smult_n(DenseVector&, double)’:
DenseVector.cpp:62:15: error: ‘class DenseVector’ has no member named ‘dim’
size_t n = w.dim();
^
make: *** [DenseVector.o] Error 1
The contents of the folder look like:
x#x-laptop:/pssp_source$ ls
common.cpp data_type_api.h DenseVector.h Main.cpp Makefile Sparm.cpp Sparm.o SparseVector.h test_model.mltr Util.h
common.h DenseVector.cpp example_data Main.o readme.pdf Sparm.h SparseVector.cpp Test.cpp test_model.mlty
I looked up the basic packages needed for compiling c++ code, as well as basics on how to run it and none have gotten me past this issue. It looks as if it has a problem with size_t not having a type.
The start of DenseVector.cpp is :
#include "DenseVector.h"
#include <cassert>
#include <iostream>
DenseVector::DenseVector(size_t n): m_dim(n)
{
m_dvector.reserve(n);
for (size_t i=0; i<n; i++)
{
m_dvector.push_back(0);
}
}
I have never compiled code like this before, so I am probably missing something obvious. If its needed I am running ubuntu 14.04, g++ version is
4.8.4.
Thanks
It sounds like the README lied. Probably it happened to work with a different version of the standard library.
Try adding
#include <stddef.h>
near the top of DenseVector.h.
Open the file DenseVector.h in the root directory of the program and modify it, inserting
#pragma once
#include <vector>
#include <cstddef> // <--- Add this line to the file
class DenseVector
{
protected:
// ...
Save it and try again!
I don't think you are using the correct version of C; I think you need C11. Instead of using the -03 flag, use -11 or -std=c11. Then recompile it.

Errors compiling very simple boost::spirit grammar

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;
}

Building C++ application with pre-build library gives compile errors

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)

Compiling C++ Thrift code to interface Cassandra results in following errors. What are we missing here?

$ g++ -lthrift -Wall thriftfs.cpp cassandra_constants.cpp Cassandra.cpp cassandra_types.cpp -o thriftfs -I/usr/local/include/thrift -L/usr/local/lib
In file included from /usr/local/include/thrift/protocol/TProtocol.h:23:0,
from /usr/local/include/thrift/TProcessor.h:24,
from Cassandra.h:10,
from t`enter code here`hriftfs.cpp:4:
/usr/local/include/thrift/transport/TTransport.h:34:1: error: ‘uint32_t’ does not name a type
/usr/local/include/thrift/transport/TTransport.h:156:29: error: ISO C++ forbids declaration of ‘buf’ with no type [-fpermissive]
In file included from /usr/local/include/thrift/TProcessor.h:24:0,
from Cassandra.h:10,
from thriftfs.cpp:4:
/usr/local/include/thrift/protocol/TProtocol.h:184:1: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:10:0,
from thriftfs.cpp:4:
/usr/local/include/thrift/TProcessor.h:72:57: error: ‘uint32_t’ has not been declared
In file included from cassandra_types.h:11:0,
from Cassandra.h:11,
from thriftfs.cpp:4:
/usr/local/include/thrift/TApplicationException.h:94:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:85:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:142:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1478:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1812:3: error: ‘uint32_t’ does not name a type
In file included from thriftfs.cpp:4:0:
Cassandra.h:217:3: error: ‘uint32_t’ does not name a type
Cassandra.h:4857:35: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4857:62: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4859:71: error: cannot declare pointer to ‘void’ member
Cassandra.h:4859:145: error: template argument 2 is invalid
Cassandra.h:4859:145: error: template argument 4 is invalid
Cassandra.h:4860:45: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4860:72: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:77: error: template argument 1 is invalid
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:140: error: template argument 1 is invalid
Cassandra.h: In constructor ‘org::apache::cassandra::CassandraProcessor::CassandraProcessor(boost::shared_ptr)’:
Cassandra.h:4898:49: error: assignment of read-only location ‘"login"[((org::apache::cassandra::CassandraProcessor*)this)->org::apache::cassandra::CassandraProcessor::processMap_]’
Cassandra.h:4898:49: error: cannot convert ‘void (org::apache::cassandra::CassandraProcessor::*)(int32_t, int) {aka void (org::apach
Add the following defines:
g++ -DHAVE_NETINET_IN_H -DHAVE_INTTYPES_H ...
Or add #include <stdint.h> before including Thrift.h in your code.
See the discussion at THRIFT-1326. The issue is suppposedly fixed in thrift 0.9.
It looks like your problem is a compiler issue.
It can't find the type "uint32_t"
There is another question on SO regarding this:
'uint32_t' identifier not found error
Quoted from user templatetypedef
This type is defined in the C header which is not currently
a part of the C++ standard. According to the Wikipedia page on the
header, it hasn't shipped with Visual Studio until VS2010.
In the meantime, you could probably fake up your own version of the
header by adding typedefs that map Microsoft's custom integer types to
the types expected by C. For example:
typedef __int32 int32_t; typedef unsigned __int32 uint32_t; /* ...
etc. ... */ Hope this helps!