hello all,

i started checking out litesql this morning for use in a project idea
i'm playing around with. the project compiles with -Wall -W -Werror
which caused a couple problems when i tried to use litesql. there's a
couple warnings in the include files and a few in the generated
hpp/cpp files. they're mostly unused parameter warnings. i have
attached a patch which fixes the problems i've run across so far.
(compiling the example program in my env.)

the trick being used to silence the warning is pretty standard, i
originally found it in perl.h (so it will compile cleanly and away to
nothing pretty much anywhere.)
    (void)unusedVarOrParam;

while i was at it i tried compiling with -pedantic which comes really
close. the only additional warnings/errors i got there were about
extra ;'s. i've fixed those in the include files (in the patch above)
but couldn't manage to fix them (quickly) in the following case:

class RoleRelation {
public:
    class Row {
    public:
        litesql::Field<int> role;
        litesql::Field<int> person;
        Row(const litesql::Database& db, const litesql::Record&
rec=litesql::Record());
    };
    static const std::string table__;
    static const litesql::FieldType Person;
    static const litesql::FieldType Role;
    static void link(const litesql::Database& db, const
example::Person& o0, const example::Role& o1);
    static void unlink(const litesql::Database& db, const
example::Person& o0, const example::Role& o1);
    static void del(const litesql::Database& db, const litesql::Expr&
expr=litesql::Expr());
    static litesql::DataSource<RoleRelation::Row> getRows(const
litesql::Database& db, const litesql::Expr& expr=litesql::Expr());
    template <class T> static litesql::DataSource<T> get(const
litesql::Database& db, const litesql::Expr& expr=litesql::Expr(),
const litesql::Expr& srcExpr=litesql::Expr());
;
;
};

digging in to it i found that there are 7 "methods" in the vector, but
the last two don't result in anything getting printed to the hpp file
with the exception of two extra ;'s someone who knows the code better
may be able to correct this which would get the example to compile
with -pedantic.

i originally tried to make the fixes against trunk out of svn, but it
wasn't compiling for me so the patch is against 0.3.3

awesome stuff, i look forward to exploring it more.

questions/comments/problems let me know.

best,
--
-rm
diff -ur /tmp/litesql-0.3.3/src/generator/litesql-gen-cpp.cpp src/generator/litesql-gen-cpp.cpp
--- /tmp/litesql-0.3.3/src/generator/litesql-gen-cpp.cpp	2008-11-12 14:53:53.000000000 -0800
+++ src/generator/litesql-gen-cpp.cpp	2009-05-01 10:55:58.000000000 -0700
@@ -437,6 +437,7 @@
     Method addUpdates("addUpdates", "void");
     addUpdates.protected_().virtual_()
         .param(Variable("updates", "Updates&"))
+        .body("(void)updates;")
         .body("prepareUpdate(updates, table__);");
     for (size_t i = 0; i < o.fields.size(); i++) {
         const xml::Field& f = *o.fields[i];
@@ -446,7 +447,8 @@
         addUpdates.body(o.inherits + "::addUpdates(updates);");
     Method addIDUpdates("addIDUpdates", "void");    
     addIDUpdates.protected_().virtual_()
-        .param(Variable("updates", "Updates&"));
+        .param(Variable("updates", "Updates&"))
+        .body("(void)updates;");
     if (o.parentObject) {
         addIDUpdates
             .body("prepareUpdate(updates, table__);")
@@ -643,6 +645,7 @@
 //        .constructor("litesql::Record(db, rec)");
     Split consParams;
     int fieldNum = r.related.size() + r.fields.size();
+    rowcons.body("(void)db;");
     rowcons.body("switch(rec.size()) {");
     for (int i = r.fields.size()-1; i >= 0; i--) {
         const xml::Field& fld = *r.fields[i];
diff -ur /tmp/litesql-0.3.3/include/litesql/backend.hpp include/litesql/backend.hpp
--- /tmp/litesql-0.3.3/include/litesql/backend.hpp	2008-11-12 04:54:32.000000000 -0800
+++ include/litesql/backend.hpp	2009-05-01 10:23:17.000000000 -0700
@@ -26,7 +26,7 @@
             iteration, this method is used to set cache size. 
             All backends do not react to this request.
         */
-        virtual void setCacheSize(int s) {}
+        virtual void setCacheSize(int s) { (void)s; }
         /** returns one result row. empty row means that result set is 
          *  iterated through */
         virtual Record fetchOne()=0;  
diff -ur /tmp/litesql-0.3.3/include/litesql/datetime.hpp include/litesql/datetime.hpp
--- /tmp/litesql-0.3.3/include/litesql/datetime.hpp	2008-11-12 04:54:32.000000000 -0800
+++ include/litesql/datetime.hpp	2009-05-01 10:09:42.000000000 -0700
@@ -112,6 +112,6 @@
 ostream& operator << (ostream& os, const Date& d);
 ostream& operator << (ostream& os, const Time& d);
 ostream& operator << (ostream& os, const DateTime& d);
-};
+}
 
 #endif
diff -ur /tmp/litesql-0.3.3/include/litesql/persistent.hpp include/litesql/persistent.hpp
--- /tmp/litesql-0.3.3/include/litesql/persistent.hpp	2008-11-12 14:46:18.000000000 -0800
+++ include/litesql/persistent.hpp	2009-05-01 10:25:11.000000000 -0700
@@ -90,7 +90,7 @@
     static Split getTablesFromFieldTypes(const std::vector<FieldType> & fdatas);
     /** class adds own tables to tables 
         \param tables initially empty Split. Tables are inserted there */
-    virtual void getTables(Split & tables) const {  }
+    virtual void getTables(Split & tables) const { (void)tables; }
 };
 
 }
diff -ur /tmp/litesql-0.3.3/include/litesql/types.hpp include/litesql/types.hpp
--- /tmp/litesql-0.3.3/include/litesql/types.hpp	2008-11-12 04:54:32.000000000 -0800
+++ include/litesql/types.hpp	2009-05-01 10:09:06.000000000 -0700
@@ -21,7 +21,7 @@
 public: 
     Record() : std::vector<std::string>() {}
     /** defined for compatibility with Persistent */
-    Record(const Database & db, const Record& r ) { *this = r;}
+    Record(const Database & db, const Record& r ) { *this = r; (void)db; }
 };
 /** shortcut */
 typedef std::vector<Record> Records;
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Litesql-users mailing list
Litesql-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/litesql-users

Reply via email to