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 ));
Related
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?
I want to learn to use shaders and therefore created a new C++ project on Netbeans (ver. 8.0.2).
I want to include the GLFW and the GLEW Library like stated in this tutorial: http://www.learnopengl.com/#!Getting-started/Creating-a-window
I'm currently struggeling at importing glew properly. When using #include <GL/glew.h>, the compiler (I use GNU g++ on Windows10x64/Cygwin console) throws a huge list of errors. It seems to be a problem with glu.h. I removed the impot of glu.h inside of glew.h for testing purposes. This removed the errors, but also prevented openGL from loading completely (functions starting with gl were "undefined", like glViewport). So that cannot be the solution.
The output I get when calling the compiler on the normal glew.h:
g++ -m64 -c -g -Wall -I/cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/ -I/cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/ -std=c++11 -MMD -MP -MF "build/Debug/Cygwin-Windows/startup.o.d" -o build/Debug/Cygwin-Windows/startup.o startup.cc
In file included from /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL/glew.h:1202:0,
from startup.cc:5:
/usr/include/w32api/GL/glu.h:68:79: error: expected ')' before '*' token
void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)());
^
/usr/include/w32api/GL/glu.h:68:79: error: expected ')' before '*' token
/usr/include/w32api/GL/glu.h:68:79: error: expected initializer before '*' token
/usr/include/w32api/GL/glu.h:78:79: error: expected ')' before '*' token
void APIENTRY gluTessCallback(GLUtesselator *tess,GLenum which,void (CALLBACK *fn)());
^
/usr/include/w32api/GL/glu.h:78:79: error: expected ')' before '*' token
/usr/include/w32api/GL/glu.h:78:79: error: expected initializer before '*' token
/usr/include/w32api/GL/glu.h:94:75: error: expected ')' before '*' token
void APIENTRY gluNurbsCallback(GLUnurbs *nobj,GLenum which,void (CALLBACK *fn)());
^
/usr/include/w32api/GL/glu.h:94:75: error: expected ')' before '*' token
/usr/include/w32api/GL/glu.h:94:75: error: expected initializer before '*' token
/usr/include/w32api/GL/glu.h:96:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUquadricErrorProc)(GLenum);
^
/usr/include/w32api/GL/glu.h:97:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessBeginProc)(GLenum);
^
/usr/include/w32api/GL/glu.h:98:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessEdgeFlagProc) (GLboolean);
^
/usr/include/w32api/GL/glu.h:99:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessVertexProc)(void *);
^
/usr/include/w32api/GL/glu.h:100:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessEndProc)(void);
^
/usr/include/w32api/GL/glu.h:101:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessErrorProc)(GLenum);
^
/usr/include/w32api/GL/glu.h:102:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessCombineProc)(GLdouble[3],void*[4],GLfloat[4],void**);
^
/usr/include/w32api/GL/glu.h:103:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessBeginDataProc)(GLenum,void *);
^
/usr/include/w32api/GL/glu.h:104:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessEdgeFlagDataProc) (GLboolean,void *);
^
/usr/include/w32api/GL/glu.h:105:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessVertexDataProc)(void *,void *);
^
/usr/include/w32api/GL/glu.h:106:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessEndDataProc)(void *);
^
/usr/include/w32api/GL/glu.h:107:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessErrorDataProc)(GLenum,void *);
^
/usr/include/w32api/GL/glu.h:108:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUtessCombineDataProc)(GLdouble[3],void*[4],GLfloat[4],void**,void*);
^
/usr/include/w32api/GL/glu.h:109:24: error: expected ')' before '*' token
typedef void (CALLBACK *GLUnurbsErrorProc)(GLenum);
^
To me, (i'm no pro in C++ and thus not very good in interpreting error messages) it seems like CALLBACK is not defined yet. Any idea on how to solve this?
I solved it somehow (not beautiful, but at least somehow):
I tried importing windef.h like stated in the link from #Louen.
This removed the CALLBACK-Error, but created a new one (something about APIENTRY). So I searched for the error-solving part of windef.h and found it:
#ifndef CALLBACK
#if defined(_ARM_)
#define CALLBACK
#else
#define CALLBACK __stdcall
#endif
#endif
Then i just pasted this in my file (instead of including whole windef.h).
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))
This question already has answers here:
Where and why do I have to put the "template" and "typename" keywords?
(8 answers)
Closed 8 years ago.
I have this strange (for me) behavior which I'm not able to explain and I wish to have your comments on this, please have a look at the following code:
void detach(callback_function_ptr const& ptr) {
observers.erase(remove_if(
observers.begin(),
observers.end(),
[&ptr](callback_function_ptr const& ptr2) {
return ptr.target<void(worker*)>() == ptr2.target<void(worker*)>();
}
));
}
When calling 'target' I need to specify which on I want to use, otherwise I get this compilation error:
test.cpp:47:44: error: no matching function for call to 'std::function<void(worker*)>::target() const'
And this is somehow understandable to me, I thought I may avoid to specify each time which 'target' function I want by preparing such a small 'helper':
template<typename T>
worker_ptr get_target(const function<T>& callback) {
return callback.target<T>();
}
Which looks a reasonable solution (to me :) ), but doesnt work:
test.cpp: In member function 'void (worker::* worker::get_target(const std::func
tion<T>&))(worker*)':
test.cpp:18:27: error: expected primary-expression before '>' token
return callback.target<T>();
^
test.cpp:18:29: error: expected primary-expression before ')' token
return callback.target<T>();
^
Well, here I don't catch the problem, why is not valid? Even if I use void(worker*) instead of T a compilation error is still present:
test.cpp:18:26: error: expected primary-expression before 'void'
return callback.target<void(worker*)>();
^
test.cpp:18:26: error: expected ';' before 'void'
test.cpp:18:26: error: expected primary-expression before 'void'
test.cpp:18:26: error: expected ';' before 'void'
I had used void(worker*) before in the 'detach' function with no problems, why here is not working? How does exactly behave the template type deduction and function call resolution in this case?
Thanks for your help
It should be (with extra template):
template<typename T>
worker_ptr get_target(const function<T>& callback)
{
return callback.template target<T>();
}
I have included #include </usr/include/c++/4.4.3/tr1/shared_ptr.h> in my class file,
When I attempt to compile my class I get below error:
> In file included from account.h:16:0:
/usr/include/c++/4.4.3/tr1/shared_ptr.h:61:46: error: '_Lock_policy' has not been declared
/usr/include/c++/4.4.3/tr1/shared_ptr.h:63:30: error: expected template-name before '<' token
/usr/include/c++/4.4.3/tr1/shared_ptr.h:63:30: error: expected '{' before '<' token
/usr/include/c++/4.4.3/tr1/shared_ptr.h:63:30: error: expected unqualified-id before '<' token
/usr/include/c++/4.4.3/tr1/shared_ptr.h:89:12: error: '_Lock_policy' has not been declared
/usr/include/c++/4.4.3/tr1/shared_ptr.h:89:31: error: '__default_lock_policy' was not declared in this scope
/usr/include/c++/4.4.3/tr1/shared_ptr.h:100:12: error: '_Lock_policy' has not been declared
/usr/include/c++/4.4.3/tr1/shared_ptr.h:100:31: error: '__default_lock_policy' was not declared in this scope
/usr/include/c++/4.4.3/tr1/shared_ptr.h:209:7: error: '_Sp_counted_base' does not name a type
/usr/include/c++/4.4.3/tr1/shared_ptr.h: In constructor 'std::tr1::__shared_count<_Lp>::__shared_count()':
Do anyone knows what exactly could be causing this errors been thrown?
I have added #include <tr1/memory> and has sorted the issue.
As of GCC 4.3, you should use:
#include <memory>
... as recommended in the gcc docs.