error: expected unqualified-id before '(' token - c++

In file included from /Boost/Implementation/boost_1_59_0/include/boost/geometry/core/radian_access.hpp:33:0,
from /Boost/Implementation/boost_1_59_0/include/boost/geometry/geometry.hpp:43,
from /../../abc.h:11,
from /../../xyz.cpp:9:
/Boost/Implementation/boost_1_59_0/include/boost/geometry/util/math.hpp: In static member function 'static bool boost::geometry::math::detail::equals<Type, true>::apply(const Type&, const Type&, const Policy&)':
/Boost/Implementation/boost_1_59_0/include/boost/geometry/util/math.hpp:166:26: error: expected unqualified-id before '(' token
/Boost/Implementation/boost_1_59_0/include/boost/geometry/util/math.hpp:166:54: error: expected unqualified-id before '(' token
The error is in the infine call from below code of math.hpp file.
if (boost::math::isfinite(a) && boost::math::isfinite(b))

Related

rapidjson error: expected unqualified-id before 'bool' when building for Linux using Bazel

I'm compiling some C++ code that compiles fine for Android and iOS but fails under Linux. I've searched around and it looks like this kind of crash shows up when the implementer does something wrong; such as, using a reserved word. However I fail to see what I am doing wrong based on the error I'm getting.
In file included from external/rapidjson_artifact/include/rapidjson/document.h:20:0,
from src/main/cc/com/mycompany/serialization/JsonSerializer.h:4,
from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com
/mycompany/model/common/Vector2d.h:13,
from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/FastVector2d.h:10,
from src/main/cc/com/mycompany/api/gestures/primitives/CalculatedElementPosition.h:7,
from src/main/cc/com/mycompany/api/gestures/primitives/PointerInteraction.h:7,
from src/main/cc/com/mycompany/api/gestures/native/NativeUserInteractionHandler.h:10,
from src/main/cc/com/mycompany/linux/api/gestures/UserInteractionHandler.h:4,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:13,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1:
external/rapidjson_artifact/include/rapidjson/reader.h:189:15: error: expected unqualified-id before 'bool'
bool Bool(bool) { return static_cast<Override&>(*this).Default(); }
^~~~
external/rapidjson_artifact/include/rapidjson/reader.h:189:15: error: expected ')' before 'bool'
In file included from /usr/include/GL/glx.h:30:0,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:7,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1:
external/rapidjson_artifact/include/rapidjson/reader.h: In member function 'void rapidjson::GenericReader<SourceEncoding, TargetEncoding, StackAllocator>::ParseTrue(InputStream&, Handler&)':
external/rapidjson_artifact/include/rapidjson/reader.h:623:26: error: expected unqualified-id before 'int'
if (!handler.Bool(true))
^
external/rapidjson_artifact/include/rapidjson/reader.h:623:26: error: expected ')' before 'int'
external/rapidjson_artifact/include/rapidjson/reader.h: In member function 'void rapidjson::GenericReader<SourceEncoding, TargetEncoding, StackAllocator>::ParseFalse(InputStream&, Handler&)':
external/rapidjson_artifact/include/rapidjson/reader.h:636:26: error: expected unqualified-id before 'int'
if (!handler.Bool(false))
^
external/rapidjson_artifact/include/rapidjson/reader.h:636:26: error: expected ')' before 'int'
external/rapidjson_artifact/include/rapidjson/document.h: In member function 'bool rapidjson::GenericValue<Encoding, Allocator>::Accept(Handler&) const':
external/rapidjson_artifact/include/rapidjson/document.h:1539:44: error: expected unqualified-id before 'int'
case kFalseType: return handler.Bool(false);
^
external/rapidjson_artifact/include/rapidjson/document.h:1539:44: error: expected ';' before 'int'
external/rapidjson_artifact/include/rapidjson/document.h:1540:44: error: expected unqualified-id before 'int'
case kTrueType: return handler.Bool(true);
^
external/rapidjson_artifact/include/rapidjson/document.h:1540:44: error: expected ';' before 'int'
In file included from src/main/cc/com/mycompany/serialization/JsonSerializer.h:4:0,
from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/Vector2d.h:13,
from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/FastVector2d.h:10,
from src/main/cc/com/mycompany/api/gestures/primitives/CalculatedElementPosition.h:7,
from src/main/cc/com/mycompany/api/gestures/primitives/PointerInteraction.h:7,
from src/main/cc/com/mycompany/api/gestures/native/NativeUserInteractionHandler.h:10,
from src/main/cc/com/mycompany/linux/api/gestures/UserInteractionHandler.h:4,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:13,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1:
external/rapidjson_artifact/include/rapidjson/document.h: At global scope:
external/rapidjson_artifact/include/rapidjson/document.h:2028:15: error: expected unqualified-id before 'bool'
bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); return true; }
^~~~
external/rapidjson_artifact/include/rapidjson/document.h:2028:15: error: expected ')' before 'bool'
In file included from src/main/cc/com/mycompany/serialization/JsonSerializer.h:6:0,
from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/Vector2d.h:13,
from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/FastVector2d.h:10,
from src/main/cc/com/mycompany/api/gestures/primitives/CalculatedElementPosition.h:7,
from src/main/cc/com/mycompany/api/gestures/primitives/PointerInteraction.h:7,
from src/main/cc/com/mycompany/api/gestures/native/NativeUserInteractionHandler.h:10,
from src/main/cc/com/mycompany/linux/api/gestures/UserInteractionHandler.h:4,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:13,
from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1:
external/rapidjson_artifact/include/rapidjson/writer.h:109:15: error: expected unqualified-id before 'bool'
bool Bool(bool b) { Prefix(b ? kTrueType : kFalseType); return WriteBool(b); }
^~~~
external/rapidjson_artifact/include/rapidjson/writer.h:109:15: error: expected ')' before 'bool'
All the errors point to rapidjson but I highly doubt that is the problem. It is probably something I'm doing wrong.
Can someone suggest what I should look for to find the root cause?

Compiling mathgl sample c++

I have installed mathgl, using:
sudo apt-get install mathgl
sudo apt-get install libmgl-dev
When i tried to compile a sample c++ program from here
#include <mgl2/qt.h>
int sample(mglGraph *gr)
{
gr->Rotate(60,40);
gr->Box();
return 0;
}
//-----------------------------------------------------
int main(int argc,char **argv)
{
mglQT gr(sample,"MathGL examples");
return gr.Run();
}
using gcc sample.cpp -lmgl-qt -lmgl
i get compiler errors at mathgl functions.
lefteris#lefteris-ubuntu:~/Documents/C++/Numerical$ gcc sample.cpp -lmgl-qt -lmgl
In file included from /usr/include/mgl2/abstract.h:27:0,
from /usr/include/mgl2/qt.h:22,
from sample.cpp:1:
/usr/include/mgl2/type.h:42:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglPoint(mglPoint &&d):x(d.x),y(d.y),z(d.z),c(d.c) {}
^
/usr/include/mgl2/type.h:42:23: error: invalid constructor; you probably meant ‘mglPoint (const mglPoint&)’
mglPoint(mglPoint &&d):x(d.x),y(d.y),z(d.z),c(d.c) {}
^
/usr/include/mgl2/type.h:117:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglColor(mglColor &&d):r(d.r),g(d.g),b(d.b),a(d.a) {}
^
/usr/include/mgl2/type.h:117:23: error: invalid constructor; you probably meant ‘mglColor (const mglColor&)’
mglColor(mglColor &&d):r(d.r),g(d.g),b(d.b),a(d.a) {}
^
In file included from /usr/include/mgl2/mgl_cf.h:24:0,
from /usr/include/mgl2/mgl.h:23,
from /usr/include/mgl2/wnd.h:23,
from /usr/include/mgl2/qt.h:36,
from sample.cpp:1:
/usr/include/mgl2/data.h:49:18: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglData(mglData &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
^
/usr/include/mgl2/data.h:49:21: error: invalid constructor; you probably meant ‘mglData (const mglData&)’
mglData(mglData &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
^
/usr/include/mgl2/data.h:570:18: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglExpr(mglExpr &&d):ex(d.ex) { d.ex=0; }
^
/usr/include/mgl2/data.h:570:21: error: invalid constructor; you probably meant ‘mglExpr (const mglExpr&)’
mglExpr(mglExpr &&d):ex(d.ex) { d.ex=0; }
^
/usr/include/mgl2/data.h:601:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglDataV(mglDataV &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk),a0(d.a0)
^
/usr/include/mgl2/data.h:601:23: error: invalid constructor; you probably meant ‘mglDataV (const mglDataV&)’
mglDataV(mglDataV &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk),a0(d.a0)
^
/usr/include/mgl2/data.h:667:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglDataW(mglDataW &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk)
^
/usr/include/mgl2/data.h:667:23: error: invalid constructor; you probably meant ‘mglDataW (const mglDataW&)’
mglDataW(mglDataW &&d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk)
^
/usr/include/mgl2/data.h:741:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglDataF(mglDataF &&d):nx(d.nx),ny(d.ny),nz(d.nz), str(d.str), v1(d.v1),v2(d.v2), ex(d.ex), dx(d.dx),dy(d.dy),dz(d.dz), dfunc(d.dfunc),par(d.par)
^
/usr/include/mgl2/data.h:741:23: error: invalid constructor; you probably meant ‘mglDataF (const mglDataF&)’
mglDataF(mglDataF &&d):nx(d.nx),ny(d.ny),nz(d.nz), str(d.str), v1(d.v1),v2(d.v2), ex(d.ex), dx(d.dx),dy(d.dy),dz(d.dz), dfunc(d.dfunc),par(d.par)
^
/usr/include/mgl2/data.h:846:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglDataT(mglDataT &&d):dat(d.dat),ind(d.ind)
^
/usr/include/mgl2/data.h:846:23: error: invalid constructor; you probably meant ‘mglDataT (const mglDataT&)’
mglDataT(mglDataT &&d):dat(d.dat),ind(d.ind)
^
/usr/include/mgl2/data.h:893:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglDataR(mglDataR &&d):dat(d.dat),ind(d.ind)
^
/usr/include/mgl2/data.h:893:23: error: invalid constructor; you probably meant ‘mglDataR (const mglDataR&)’
mglDataR(mglDataR &&d):dat(d.dat),ind(d.ind)
^
In file included from /usr/include/mgl2/mgl_cf.h:25:0,
from /usr/include/mgl2/mgl.h:23,
from /usr/include/mgl2/wnd.h:23,
from /usr/include/mgl2/qt.h:36,
from sample.cpp:1:
/usr/include/mgl2/datac.h:50:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
mglDataC(mglDataC &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
^
/usr/include/mgl2/datac.h:50:23: error: invalid constructor; you probably meant ‘mglDataC (const mglDataC&)’
mglDataC(mglDataC &&d):nx(d.nx),ny(d.ny),nz(d.nz),a(d.a),id(d.id),link(d.link)
^
i tried running the python sample, and it worked fine.
Does anyone know how to fix this problem?

Compiling a quickfix program

I am trying to use the quickfix library to connect to a broker using the FIX protocol. I just built the library using the documentation they provide and use their sample code right now
#include "quickfix/FileStore.h"
#include "quickfix/FileLog.h"
#include "quickfix/SocketAcceptor.h"
#include "quickfix/Session.h"
#include "quickfix/SessionSettings.h"
#include "quickfix/Application.h"
int main( int argc, char** argv )
{
try
{
if(argc < 2) return 1;
std::string fileName = argv[1];
FIX::SessionSettings settings(fileName);
MyApplication application;
FIX::FileStoreFactory storeFactory(settings);
FIX::FileLogFactory logFactory(settings);
FIX::SocketAcceptor acceptor
(application, storeFactory, settings, logFactory /*optional*/);
acceptor.start();
// while( condition == true ) { do something; }
acceptor.stop();
return 0;
}
catch(FIX::ConfigError& e)
{
std::cout << e.what();
return 1;
}
}
However, when I try to compile it with:
g++ fix.cpp -fexceptions -finline-functions -lquickfix -lpthread -lxml2
I get a bunch of errors:
In file included from /usr/local/include/quickfix/Session.h:34:0,
from fix.cpp:6:
/usr/local/include/quickfix/DataDictionaryProvider.h:54:72: error: ‘ptr::shared_ptr’ has not been declared
void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:54:82: error: expected ‘,’ or ‘...’ before ‘<’ token
void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:55:70: error: ‘ptr::shared_ptr’ has not been declared
void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:55:80: error: expected ‘,’ or ‘...’ before ‘<’ token
void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:25: error: ‘shared_ptr’ is not a member of ‘ptr’
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:25: error: ‘shared_ptr’ is not a member of ‘ptr’
/usr/local/include/quickfix/DataDictionaryProvider.h:63:55: error: template argument 2 is invalid
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:55: error: template argument 4 is invalid
/usr/local/include/quickfix/DataDictionaryProvider.h:63:57: error: expected unqualified-id before ‘>’ token
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:25: error: ‘shared_ptr’ is not a member of ‘ptr’
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:25: error: ‘shared_ptr’ is not a member of ‘ptr’
/usr/local/include/quickfix/DataDictionaryProvider.h:64:55: error: template argument 2 is invalid
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:55: error: template argument 4 is invalid
/usr/local/include/quickfix/DataDictionaryProvider.h:64:57: error: expected unqualified-id before ‘>’ token
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h: In member function ‘void FIX::DataDictionaryProvider::addTransportDataDictionary(const FIX::BeginString&, const string&)’:
/usr/local/include/quickfix/DataDictionaryProvider.h:58:45: error: ‘shared_ptr’ is not a member of ‘ptr’
{ addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
/usr/local/include/quickfix/DataDictionaryProvider.h:58:75: error: expected primary-expression before ‘>’ token
{ addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
/usr/local/include/quickfix/DataDictionaryProvider.h: In member function ‘void FIX::DataDictionaryProvider::addApplicationDataDictionary(const FIX::ApplVerID&, const string&)’:
/usr/local/include/quickfix/DataDictionaryProvider.h:60:45: error: ‘shared_ptr’ is not a member of ‘ptr’
{ addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
/usr/local/include/quickfix/DataDictionaryProvider.h:60:75: error: expected primary-expression before ‘>’ token
{ addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
fix.cpp: In function ‘int main(int, char**)’:
fix.cpp:19:5: error: ‘MyApplication’ was not declared in this scope
MyApplication application;
^
fix.cpp:19:19: error: expected ‘;’ before ‘application’
MyApplication application;
^
fix.cpp:23:8: error: ‘application’ was not declared in this scope
(application, storeFactory, settings, logFactory /*optional*/);
^
root#luis:/home/luis/tradingbot/bot4# In file included from /usr/local/include/quickfix/Session.h:34:0,
In: command not found
root#luis:/home/luis/tradingbot/bot4# from fix.cpp:6:
from: can't read /var/mail/fix.cpp:6:
root#luis:/home/luis/tradingbot/bot4# /usr/local/include/quickfix/DataDictionaryProvider.h:54:72: error: ‘ptr::shared_ptr’ has not been declared
bash: /usr/local/include/quickfix/DataDictionaryProvider.h:54:72:: No such file or directory
root#luis:/home/luis/tradingbot/bot4# void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
bash: syntax error near unexpected token `('
root#luis:/home/luis/tradingbot/bot4# ^
^: command not found
root#luis:/home/luis/tradingbot/bot4# /usr/local/include/quickfix/DataDictionaryProvider.h:54:82: error: expected ‘,’ or ‘...’ before ‘<’ token
bash: ’: No such file or directory
root#luis:/home/luis/tradingbot/bot4# void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
bash: syntax error near unexpected token `('
root#luis:/home/luis/tradingbot/bot4# ^
^: command not found
root#luis:/home/luis/tradingbot/bot4# /usr/local/include/quickfix/DataDictionaryProvider.h:55:70: error: ‘ptr::shared_ptr’ has not been declared
bash: /usr/local/include/quickfix/DataDictionaryProvider.h:55:70:: No such file or directory
What am I doing wrong?
You need to provide an implementation of the MyApplication class and compile with the appropriate C++11 flags.
Your MyApplication object typically needs to derive from the FIX::Application class which is a pure virtual class and will require you to implement a series of methods such as onLogon(...) and toApp(...)
If you want to just get your code to compile as a first step you can try using the FIX::NullApplication class (defined in quickfix/Application.h) as your starting application object.
The quickfix library must be compiled with this pre-processor directive HAVE_STD_UNIQUE_PTR
Your application must provide an implementation for the MyApplication class and that implementation must inherit from FIX::Application

Numerical Recipes v3.0 and pthread library in C++11

If I compile the following code with the command g++ -std=c++11 Threads.cpp -lpthread -I../Libs/nr30, where nr30 is the library provided by http://www.nr.com/, I obtain no errors:
#include <chrono>
#include <thread>
int main(void) {
/* ... Sadly, No further code in here was added... */
}
while if I add the #include "nr3.h" header in the same code as above, I obtain the following error:
In file included from /usr/include/c++/4.7/memory:76:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/ext/concurrence.h:73:5: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/ext/concurrence.h:72:5: error: looser throw specifier for ‘virtual const char* __gnu_cxx::__concurrence_lock_error::what() const’
In file included from /usr/include/c++/4.7/ios:40:0,
from /usr/include/c++/4.7/istream:40,
from /usr/include/c++/4.7/fstream:40,
from ../Libs/nr30/nr3.h:10,
from random_test.cpp:29:
/usr/include/c++/4.7/exception:70:25: error: overriding ‘virtual const char* std::exception::what() const noexcept (true)’
In file included from /usr/include/c++/4.7/memory:76:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/ext/concurrence.h: In member function ‘virtual const char* __gnu_cxx::__concurrence_lock_error::what() const’:
/usr/include/c++/4.7/ext/concurrence.h:72:18: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/ext/concurrence.h: At global scope:
/usr/include/c++/4.7/ext/concurrence.h:81:5: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/ext/concurrence.h:80:5: error: looser throw specifier for ‘virtual const char* __gnu_cxx::__concurrence_unlock_error::what() const’
In file included from /usr/include/c++/4.7/ios:40:0,
from /usr/include/c++/4.7/istream:40,
from /usr/include/c++/4.7/fstream:40,
from ../Libs/nr30/nr3.h:10,
from random_test.cpp:29:
/usr/include/c++/4.7/exception:70:25: error: overriding ‘virtual const char* std::exception::what() const noexcept (true)’
In file included from /usr/include/c++/4.7/memory:76:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/ext/concurrence.h: In member function ‘virtual const char* __gnu_cxx::__concurrence_unlock_error::what() const’:
/usr/include/c++/4.7/ext/concurrence.h:80:18: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/ext/concurrence.h: At global scope:
/usr/include/c++/4.7/ext/concurrence.h:89:5: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/ext/concurrence.h:88:5: error: looser throw specifier for ‘virtual const char* __gnu_cxx::__concurrence_broadcast_error::what() const’
In file included from /usr/include/c++/4.7/ios:40:0,
from /usr/include/c++/4.7/istream:40,
from /usr/include/c++/4.7/fstream:40,
from ../Libs/nr30/nr3.h:10,
from random_test.cpp:29:
/usr/include/c++/4.7/exception:70:25: error: overriding ‘virtual const char* std::exception::what() const noexcept (true)’
In file included from /usr/include/c++/4.7/memory:76:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/ext/concurrence.h: In member function ‘virtual const char* __gnu_cxx::__concurrence_broadcast_error::what() const’:
/usr/include/c++/4.7/ext/concurrence.h:88:18: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/ext/concurrence.h: At global scope:
/usr/include/c++/4.7/ext/concurrence.h:97:5: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/ext/concurrence.h:96:5: error: looser throw specifier for ‘virtual const char* __gnu_cxx::__concurrence_wait_error::what() const’
In file included from /usr/include/c++/4.7/ios:40:0,
from /usr/include/c++/4.7/istream:40,
from /usr/include/c++/4.7/fstream:40,
from ../Libs/nr30/nr3.h:10,
from random_test.cpp:29:
/usr/include/c++/4.7/exception:70:25: error: overriding ‘virtual const char* std::exception::what() const noexcept (true)’
In file included from /usr/include/c++/4.7/memory:76:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/ext/concurrence.h: In member function ‘virtual const char* __gnu_cxx::__concurrence_wait_error::what() const’:
/usr/include/c++/4.7/ext/concurrence.h:96:18: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/ext/concurrence.h: At global scope:
/usr/include/c++/4.7/ext/concurrence.h:309:5: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/ext/concurrence.h: In destructor ‘__gnu_cxx::__scoped_lock::~__scoped_lock()’:
/usr/include/c++/4.7/ext/concurrence.h:308:22: error: expected primary-expression before ‘,’ token
In file included from /usr/include/c++/4.7/memory:84:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/backward/auto_ptr.h: At global scope:
/usr/include/c++/4.7/backward/auto_ptr.h:90:12: error: invalid use of non-static data member ‘std::auto_ptr<_Tp>::_M_ptr’
/usr/include/c++/4.7/backward/auto_ptr.h:103:49: error: from this location
/usr/include/c++/4.7/backward/auto_ptr.h:103:56: error: ‘__p’ was not declared in this scope
/usr/include/c++/4.7/backward/auto_ptr.h:103:59: error: expected ‘;’ at end of member declaration
/usr/include/c++/4.7/backward/auto_ptr.h:103:61: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:90:12: error: invalid use of non-static data member ‘std::auto_ptr<_Tp>::_M_ptr’
/usr/include/c++/4.7/backward/auto_ptr.h:112:41: error: from this location
/usr/include/c++/4.7/backward/auto_ptr.h:112:48: error: ‘__a’ was not declared in this scope
/usr/include/c++/4.7/backward/auto_ptr.h:112:61: error: expected ‘;’ at end of member declaration
/usr/include/c++/4.7/backward/auto_ptr.h:112:63: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:90:12: error: invalid use of non-static data member ‘std::auto_ptr<_Tp>::_M_ptr’
/usr/include/c++/4.7/backward/auto_ptr.h:125:49: error: from this location
/usr/include/c++/4.7/backward/auto_ptr.h:125:56: error: ‘__a’ was not declared in this scope
/usr/include/c++/4.7/backward/auto_ptr.h:125:69: error: expected ‘;’ at end of member declaration
/usr/include/c++/4.7/backward/auto_ptr.h:125:71: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:137:7: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:155:9: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:182:7: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:195:7: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:211:27: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:226:7: error: expected unqualified-id before ‘{’ token
/usr/include/c++/4.7/backward/auto_ptr.h:241:7: error: expected unqualified-id before ‘{’ token
random_test.cpp:126:1: error: expected ‘}’ at end of input
In file included from /usr/include/c++/4.7/memory:84:0,
from /usr/include/c++/4.7/thread:40,
from random_test.cpp:34:
/usr/include/c++/4.7/backward/auto_ptr.h: In constructor ‘std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp>::element_type*)’:
/usr/include/c++/4.7/backward/auto_ptr.h:103:39: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In copy constructor ‘std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp>&)’:
/usr/include/c++/4.7/backward/auto_ptr.h:112:31: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In constructor ‘std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp1>&)’:
/usr/include/c++/4.7/backward/auto_ptr.h:125:39: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘std::auto_ptr<_Tp>& std::auto_ptr<_Tp>::operator=(std::auto_ptr<_Tp>&)’:
/usr/include/c++/4.7/backward/auto_ptr.h:136:32: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘std::auto_ptr<_Tp>& std::auto_ptr<_Tp>::operator=(std::auto_ptr<_Tp1>&)’:
/usr/include/c++/4.7/backward/auto_ptr.h:154:40: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘std::auto_ptr<_Tp>::element_type& std::auto_ptr<_Tp>::operator*() const’:
/usr/include/c++/4.7/backward/auto_ptr.h:181:25: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘std::auto_ptr<_Tp>::element_type* std::auto_ptr<_Tp>::operator->() const’:
/usr/include/c++/4.7/backward/auto_ptr.h:194:26: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘std::auto_ptr<_Tp>::element_type* std::auto_ptr<_Tp>::get() const’:
/usr/include/c++/4.7/backward/auto_ptr.h:211:19: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘std::auto_ptr<_Tp>::element_type* std::auto_ptr<_Tp>::release()’:
/usr/include/c++/4.7/backward/auto_ptr.h:225:17: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: In member function ‘void std::auto_ptr<_Tp>::reset(std::auto_ptr<_Tp>::element_type*)’:
/usr/include/c++/4.7/backward/auto_ptr.h:240:36: error: expected primary-expression before ‘,’ token
/usr/include/c++/4.7/backward/auto_ptr.h: At global scope:
/usr/include/c++/4.7/backward/auto_ptr.h:240:36: error: expected unqualified-id at end of input
/usr/include/c++/4.7/backward/auto_ptr.h:240:36: error: expected ‘}’ at end of input
make: *** [rtest] Error 1
Did you encounter the same problem? Thank you for any advice.
It looks like the authors of this library are defining their own exception classes and they forgot to mark the what() method as noexcept when the code is compiled with C++11 (or they are deriving from deprecated exception classes, e.g. TR1). This reproduces the problem:
#include <stdexcept>
struct my_exception : std::exception
{
const char* what() const { return "what"; }
};
int main()
{
}
and this fixes it:
#include <stdexcept>
struct my_exception : std::exception
{
const char* what() const noexcept { return "what"; }
// ^^^^^^^^
};
int main()
{
}
This means you either have to patch the library yourself (if you have access to the full source code) or you send them a bug report.
(you should still consider using -pthread instead of -lpthread, it's much cleaner and avoids further bugs)

C++ expected `)' before ';' token expected primary-expression before ')' token

Hello there I am iplementingh a binary tree based on an underlying array.
My project is comprises a set of c++ files and the makefile for generating the compilation.
I am using g++ provided with DEV-C++ 4.9.9.2.
Upon launching compilation I get the following two set of errors.
AlberoBinariov.h: In member function bool AlberoBinariov<T>::figlioSinistroVuoto(typename Alberoa<T, int>::posizioneNodo)':
AlberoBinariov.h:198: error: expected)' before ';' token
AlberoBinariov.h:198: error: expected primary-expression before ')' token
AlberoBinariov.h:198: error: expected `;' before ')' token
AlberoBinariov.h: In member function bool AlberoBinariov<T>::figlioDestroVuoto(typename Alberoa<T, int>::posizioneNodo)':
AlberoBinariov.h:204: error: expected)' before ';' token
AlberoBinariov.h:204: error: expected )' before ';' token
AlberoBinariov.h:204: error: expected primary-expression before ')' token
AlberoBinariov.h:204: error: expected;' before ')' token
Interested portions of code are provided below:
template <class T>
bool AlberoBinariov<T>::figlioSinistroVuoto(posizioneNodo p)
{
return (figlioSinistro(p)==(posizioneNodo)P_NULL); //line 198
}
template <class T>
bool AlberoBinariov<T>::figlioDestroVuoto(posizioneNodo p)
{
return (figlioDestro(p)==((posizioneNodo)P_NULL)); //line 204
}
also for your convenince I have included the full source code at the link below.
https://filetea.me/t1sc3e60
Can you please let me know? thanks you in advance for your time. I look forward to hear from you.
Kind regards,
Gerald
PS: P_NULL is a NULL pointer constant declared in the Constants.h file.
You have 3 individual right parenthesis without their corresponding left parenthesis:
return (figlioDestro(p) == ((posizioneNodo)P_NULL)) /* -> */ )));
Change it to this:
return (figlioDestro(p) == ( (posizioneNodo)P_NULL ));