Discussion:
[Cppcms-users] Including pool.h requires including backend.h
Josh Hunsaker
2017-01-18 23:28:23 UTC
Permalink
In gcc version 4.8.5 the following code fails to compile, and
gives an error about forward declaration of class
cppdb::backend::connection

#include <cppdb/frontend.h>
#include <cppdb/pool.h>
int main() {}

However, the following code will compile without error:

#include <cppdb/frontend.h>
#include <cppdb/backend.h>
#include <cppdb/pool.h>
int main() {}

Would it be reasonable to include backend.h from pool.h? I
verified that cppdb builds successfully for me with that change,
but I didn't know if there were other compilers for which it will
not work. The patch is as follows:

diff -u a/cppdb/pool.h b/cppdb/pool.h
--- a/cppdb/pool.h
+++ b/cppdb/pool.h
@@ -22,6 +22,7 @@
#include <cppdb/ref_ptr.h>
#include <cppdb/mutex.h>
#include <cppdb/utils.h>
+#include <cppdb/backend.h>
#include <memory>
#include <list>

Loading...