Hi,
attached are two patches fixing minor compilation problems for gcc.

patches:
0002 of them removes the char* message of a bad_cast.
bad_cast(const char*) is non-standard (18.5.2 c++98 18.7.2 c++0x) it
won't compile with gcc 4.5
maybe soci_error should be used instead?

0001 just adds missing includes.

but this brings me to another point:
the #includes in the soci headers are all just filenames without paths
this creates a problem when users include the main header and a backend
header like this:
#include <soci/soci.h>
#include <soci/sqlite3/soci-sqlite3.h>
and forget to add -I/usr/include/soci.

This leads to an error message not easily understood by beginners as it
not originates from their own code:
/usr/include/soci/sqlite3/soci-sqlite3.h:27:26: fatal error:
soci-backend.h: No such file or directory

see also the bug reports:
https://bugs.launchpad.net/ubuntu/+source/soci/+bug/529376
https://bugs.launchpad.net/ubuntu/+source/soci/+bug/690479

While this is a user error (they should add the include path to the
compiler) I'm wondering if this can be avoided by changing the includes
to relative paths in the soci header directory:
#include <soci/soci-backend.h>
This the avoids the need for the -I/usr/include/soci
The boost headers do it like this too.

The alternative would be to update the documentation to mention the
required include path.

Another good addition for easier use would be to add pkg-config support
I could provide a patch for this if you wish

Best Regards,
Julian Taylor
From 8a03e098fe13a5f9497bf2b540eb7f4e914eb5e7 Mon Sep 17 00:00:00 2001
From: Julian Taylor <[email protected]>
Date: Mon, 20 Dec 2010 22:55:53 +0100
Subject: [PATCH 1/2] add missing includes
 * error.h for soci_error
 * limits for std::numeric_limits

---
 src/backends/sqlite3/common.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/backends/sqlite3/common.h b/src/backends/sqlite3/common.h
index e855582..e1cfbc6 100644
--- a/src/backends/sqlite3/common.h
+++ b/src/backends/sqlite3/common.h
@@ -8,11 +8,13 @@
 #ifndef SOCI_SQLITE3_COMMON_H_INCLUDED
 #define SOCI_SQLITE3_COMMON_H_INCLUDED
 
+#include <error.h>
 #include <cstddef>
 #include <cstdio>
 #include <cstring>
 #include <ctime>
 #include <vector>
+#include <limits>
 
 namespace soci { namespace details { namespace sqlite3 {
 
-- 
1.7.1

From ad524ebb7c0ba92bc1f09261fcf1baa9fa9722ab Mon Sep 17 00:00:00 2001
From: Julian Taylor <[email protected]>
Date: Mon, 20 Dec 2010 22:56:50 +0100
Subject: [PATCH 2/2] fix nonstandard bad_cast use

---
 src/core/test/common-tests.h |    1 +
 src/core/type-holder.h       |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/core/test/common-tests.h b/src/core/test/common-tests.h
index 2340ec8..594e13e 100644
--- a/src/core/test/common-tests.h
+++ b/src/core/test/common-tests.h
@@ -26,6 +26,7 @@
 #include <cmath>
 #include <iostream>
 #include <string>
+#include <typeinfo>
 
 // Objects used later in tests 14,15
 struct PhonebookEntry
diff --git a/src/core/type-holder.h b/src/core/type-holder.h
index 36abf51..024f485 100644
--- a/src/core/type-holder.h
+++ b/src/core/type-holder.h
@@ -37,7 +37,7 @@ public:
         }
         else
         {
-            throw std::bad_cast("type_holder bad cast");
+            throw std::bad_cast();
         }
     }
 
-- 
1.7.1

Attachment: signature.asc
Description: This is a digitally signed message part

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to