"'assert’ was not declared in this scope" in MySQL++
Solution 1
In c++ adding cassert header should fix your problem.
#include <cassert>
Solution 2
The most obvious answer would be that "assert.h" is not being included or is not being found in your include path. Another explanation is that the assert macro has been undefined at some point after the header was included.
Edit: Since you say that assert.h is included, and we'll assume for the moment that it's being found since it's a standard header, then that leaves us with the last possibility I stated above i.e. that the macro has been undefined.
Since cpool.h itself will not be doing this it must be the case that assert.h is included earlier either by yourself or indirectly by another 3rd party header and the undefining happening between this and your inclusion of cpool.h. This can easily be tested by moving your cpool.h include to the top of your file.
Solution 3
It could be that another library in your include path has a different "assert.h" file, and you are unknowingly including that one instead of the system's standard <assert.h>.
I ran into this issue when writing an application that uses gstreamer on Mac OSX. It turns out that gstreamer's include directory (/Library/Frameworks/GStreamer.framework/Headers) includes a file "assert.h", which is non-standard and an unsuitable replacement for the real assert.h. When I added -I/Library/Frameworks/GStreamer.frameworks/Headers to my compilation command, suddenly my sources, which just said "#include <assert.h>" where including the gstreamer version. This caused my compilation to fail with the same error you were getting.
Related videos on Youtube
Anonymous
Updated on July 09, 2022Comments
-
Anonymous almost 2 years
I'm compiling a project in XCode where MySQL++ in included and linked to. For some reason, I keep getting the following compiler error:
'assert’ was not declared in this scope
originating from cpool.h, a header file that's part of MySQL++. Does anyone know why this is being triggered?
EDIT: For reference, MySQL++ was installed via Macports.
-
Anonymous almost 14 yearsThe file is being included by proxy through: #include <mysql++.h>. I have moved this to the very top of the file but I'm still getting these errors.
-
Troubadour almost 14 years@Anonymous: Is the file that includes mysql++.h a header itself?
-
Anonymous almost 14 yearsYes, but moving it the proper .cpp file still yields the same error.
-
Troubadour almost 14 years@Anonymous: So if you create a source file with only the line
#include <mysql++.h>
in it does it compile? -
Troubadour almost 14 years@Anonymous: BTW, when you say you get the same error after moving your header to the top of your source file is it coming from that particular include or is it now coming from another indirect include of cpool.h later on?
-
Anonymous almost 14 yearsAs I have moved the #include to the source file, the error is now coming from there, again, from within that #include's file mysql++.h which included cpool.h by proxy.
-
Troubadour almost 14 years@Anonymous: Have you tried to compile a source file with only the line
#include<mysql++.h>
in it? That works for me on Linux. -
Anonymous almost 14 yearsCompiling a new source file with just that one line yields the same error.
-
Troubadour almost 14 years@Anonymous: OK, I give up :) Sounds like the bug is genuinely in the version of MySQL++ you got from Macports.