List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:February 7 2005 6:15am
Subject:[PATCH] mysql++ and strict compiler warnings
View as plain text  
Hi,

I was experimenting with a project of mine, trying to trim its size
and work with various compiler options, and mysql++ ended up giving a
lot of warnings in the mode I was working with.

So... many hours later and many builds later, I've fixed mysql++ to
compile almost completely cleanly with a configure line like this:

export CXXFLAGS="-g -O2 -ansi -pedantic -Wall -W -Wold-style-cast -Wfloat-equal
-Wwrite-strings -Woverloaded-virtual -Wno-long-long"
./configure --enable-exception

The 3 types of warnings that remain are:
	- some weird one about base_ios<> not being initialized in the
		query class copy constructors... I'm not sure the iostreams
		library was meant to be copied, but mysql++ tries it anyway :-)
		The GNU commoncpp people seem to have run into this one as well
		and there were comments it may be a compiler bug.  I left it.
	- a warning each for float and double comparisons with ==
		this is not guaranteed to succeed, since precision needs
		to be taken into account... it might be something to add to
		the wishlist, to have a specialized double and float comparison
		class which allows the programmer to specify precision

Here are the things that have been fixed:
	- lots of old style casts converted to static_cast<>, or just removed
		entirely if not needed
	- the snprintf() format flags were incorrect in sql_string.cpp,
		with the size flags in the wrong order (%dh instead of %hd, etc)
		Plus, some flags are not portable... there were "%uL" flags
		for ulonglong types, and I'm not sure where that came from,
		as it's not documented for linux or microsoft.  I used
		the linux way of "%llu" for ulonglong in this patch.
		We may need to patch in "%I64u" for microsoft.
	- there were functions with unused arguments, which I fixed by
		commenting out the argument name
	- the g++ compiler warns about base classes that are not initialized
		in derived copy constructors, so in one place I added
		an empty constructor just to appease it
		(in the Result copy construct in result.h, the
		const_subscript_container<> base class was not copied)
	- small warning where g++ is not smart enough to know that
		'success' won't be used uninitialized in examples/util.cpp
	- changed Row's constructor to use an unsigned long* instead of
		unsigned int*, since mysql_fetch_lengths() returns
		unsigned long* and it makes sense to use it.
	- static char *names[]; in custom-macros.h (and custom.pl) should
		be const

This is definitely pedantic territory, but I figure if someone wants to
use this strict checking, mysql++ shouldn't stand in the way.

Note: I've not included the auto-generated files, since lists.mysql.com
won't allow messages over 30000 bytes.

- Chris





This is the patch I posted for debugging earlier.  I think it's a good idea
to put in the main tree, since at() will throw on out-of-bounds, and [] won't.

Up to you Warren. :-)


Index: software/mysql++/lib/row.cpp
diff -u software/mysql++/lib/row.cpp:1.1.1.2 software/mysql++/lib/row.cpp:1.2
--- software/mysql++/lib/row.cpp:1.1.1.2	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/row.cpp	Fri Feb  4 23:03:10 2005
@@ -18,7 +18,7 @@
 			return ColData();
 	}
 	
-	return ColData(data[i].c_str(), res->types(i), is_nulls[i]);
+	return ColData(data.at(i).c_str(), res->types(i), is_nulls[i]);
 }
 
 const ColData Row::lookup_by_name(const char* i) const




----------------------------------------
The pedantic fixes below:



Index: software/mysql++/strict-config
diff -u /dev/null software/mysql++/strict-config:1.1
--- /dev/null	Mon Feb  7 00:40:03 2005
+++ software/mysql++/strict-config	Mon Feb  7 00:21:52 2005
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export CXXFLAGS="-g -O2 -ansi -pedantic -Wall -W -Wold-style-cast -Wfloat-equal
-Wwrite-strings -Woverloaded-virtual -Wno-long-long"
+
+./configure --enable-exception
+
Index: software/mysql++/examples/cgi_image.cpp
diff -u software/mysql++/examples/cgi_image.cpp:1.1.1.1
software/mysql++/examples/cgi_image.cpp:1.2
--- software/mysql++/examples/cgi_image.cpp:1.1.1.1	Thu Dec  9 20:00:35 2004
+++ software/mysql++/examples/cgi_image.cpp	Sun Feb  6 17:56:45 2005
@@ -23,7 +23,7 @@
 	Connection con(use_exceptions);
 	try {
 		con.real_connect(MY_DATABASE, MY_HOST, MY_USER, MY_PASSWORD, 3306,
-						 (int) 0, 60, NULL);
+						 0, 60, NULL);
 		Query query = con.query();
 		query << "SELECT " << MY_FIELD << " FROM " << MY_TABLE <<
" WHERE "
 			<< MY_KEY << " = " << argv[1];
Index: software/mysql++/examples/load_file.cpp
diff -u software/mysql++/examples/load_file.cpp:1.1.1.1
software/mysql++/examples/load_file.cpp:1.2
--- software/mysql++/examples/load_file.cpp:1.1.1.1	Thu Dec  9 20:00:35 2004
+++ software/mysql++/examples/load_file.cpp	Sun Feb  6 17:56:45 2005
@@ -28,7 +28,7 @@
 	Connection con(use_exceptions);
 	try {
 		con.real_connect(MY_DATABASE, MY_HOST, MY_USER, MY_PASSWORD, 3306,
-						 (int) 0, 60, NULL);
+						 0, 60, NULL);
 		Query query = con.query();
 		ostringstream strbuf;
 		ifstream In(argv[1], ios::in | ios::binary);
Index: software/mysql++/examples/updel.cpp
diff -u software/mysql++/examples/updel.cpp:1.1.1.1
software/mysql++/examples/updel.cpp:1.2
--- software/mysql++/examples/updel.cpp:1.1.1.1	Thu Dec  9 20:00:35 2004
+++ software/mysql++/examples/updel.cpp	Sun Feb  6 17:56:45 2005
@@ -21,7 +21,7 @@
 		ostringstream strbuf;
 		unsigned int i = 0;
 		con.real_connect(MY_DATABASE, MY_HOST, MY_USER, MY_PASSWORD, 3306,
-						 (int) 0, 60, NULL);
+						 0, 60, NULL);
 		Query query = con.query();
 		query << MY_QUERY;
 		ResUse res = query.use();
@@ -36,7 +36,7 @@
 		string output(strbuf.str());
 		output.erase(output.size() - 1, 1);
 		output += ")";
-		query.exec((const string &) output);	// cout << output << endl;
+		query.exec(output);	// cout << output << endl;
 		return 0;
 	}
 	catch (BadQuery& er) {
Index: software/mysql++/examples/util.cpp
diff -u software/mysql++/examples/util.cpp:1.1.1.1 software/mysql++/examples/util.cpp:1.2
--- software/mysql++/examples/util.cpp:1.1.1.1	Thu Dec  9 20:00:35 2004
+++ software/mysql++/examples/util.cpp	Sun Feb  6 17:56:45 2005
@@ -77,7 +77,7 @@
 		kdb = kpcSampleDatabase;
 	}
 
-	bool success;
+	bool success = false;
 	if (argc == 1) {
 		success = con.connect(kdb);
 	}
Index: software/mysql++/lib/coldata.h
diff -u software/mysql++/lib/coldata.h:1.1.1.4 software/mysql++/lib/coldata.h:1.4
--- software/mysql++/lib/coldata.h:1.1.1.4	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/coldata.h	Sun Feb  6 17:56:45 2005
@@ -85,18 +85,18 @@
 	inline const bool is_null(void) const {return _null;}
 	inline const std::string&  get_string(void) const {return buf;}
   operator cchar*() const {return buf.c_str();}
-  operator  signed char() const {return conv((signed char)0);}
-  operator  unsigned char() const {return conv((unsigned char)0);}
-  operator  int() const {return conv((int)0);}
-  operator  unsigned int() const {return conv((unsigned int)0);}
-  operator  short int() const {return conv((short int)0);}
-  operator  unsigned short int() const {return conv((unsigned short int)0);}
-  operator  long int() const {return conv((long int)0);}
-  operator  unsigned long int() const {return conv((unsigned long int)0);}
-  operator  longlong() const {return conv((longlong)0);}
-  operator  ulonglong() const {return conv((ulonglong)0);}
-  operator  float() const {return conv((float)0);}
-  operator  double() const {return conv((double)0);}
+  operator  signed char() const {return conv(static_cast<signed char>(0));}
+  operator  unsigned char() const {return conv(static_cast<unsigned char>(0));}
+  operator  int() const {return conv(static_cast<int>(0));}
+  operator  unsigned int() const {return conv(static_cast<unsigned int>(0));}
+  operator  short int() const {return conv(static_cast<short int>(0));}
+  operator  unsigned short int() const {return conv(static_cast<unsigned short
int>(0));}
+  operator  long int() const {return conv(static_cast<long int>(0));}
+  operator  unsigned long int() const {return conv(static_cast<unsigned long
int>(0));}
+  operator  longlong() const {return conv(static_cast<longlong>(0));}
+  operator  ulonglong() const {return conv(static_cast<ulonglong>(0));}
+  operator  float() const {return conv(static_cast<float>(0));}
+  operator  double() const {return conv(static_cast<double>(0));}
 
   template <class T, class B> operator Null<T,B> () const;
 };
@@ -117,10 +117,10 @@
 #define oprsw(opr, other, conv) \
   template<class Str> \
   inline other operator opr (ColData_Tmpl<Str> x, other y) \
-    {return (conv)x opr y;} \
+    {return static_cast<conv>(x) opr y;} \
   template<class Str> \
   inline other operator opr (other x, ColData_Tmpl<Str> y) \
-    {return x opr (conv)y;}
+    {return x opr static_cast<conv>(y);}
 
 #define operator_binary(other, conv) \
   oprsw(+, other, conv) \
@@ -166,7 +166,7 @@
 
 
 template <class Str> template<class Type> 
-Type ColData_Tmpl<Str>::conv (Type dummy) const {
+Type ColData_Tmpl<Str>::conv (Type /*dummy*/) const {
 	std::string strbuf = buf;
 	strip_all_blanks(strbuf);
   size_t len = strbuf.size();
Index: software/mysql++/lib/compare.h
diff -u software/mysql++/lib/compare.h:1.1.1.4 software/mysql++/lib/compare.h:1.4
--- software/mysql++/lib/compare.h:1.1.1.4	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/compare.h	Mon Feb  7 00:21:52 2005
@@ -27,7 +27,7 @@
   MysqlCmpCStr(uint i, const BinaryPred &f, const char* c) : MysqlCmp<BinaryPred,
const char *> (i,f,c) {}
   bool operator () (const Row& cmp1) const 
     {return MysqlCmp<BinaryPred, const char*>::func(
-			MysqlCmp<BinaryPred, const char*>::cmp2, cmp1[index]);}
+			MysqlCmp<BinaryPred, const char*>::cmp2, cmp1[this->index]);}
 };
 
 //: A special function for using in find_if function where i is the field index number.
Index: software/mysql++/lib/connection.h
diff -u software/mysql++/lib/connection.h:1.1.1.4 software/mysql++/lib/connection.h:1.4
--- software/mysql++/lib/connection.h:1.1.1.4	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/connection.h	Sun Feb  6 17:56:45 2005
@@ -118,7 +118,7 @@
 	std::string infoo (void) {return info ();}
 	st_mysql_options get_options (void) const {return mysql.options;}
 	int read_options(enum mysql_option option,const char *arg) {return 
mysql_options(&mysql, option,arg);}
-  my_ulonglong affected_rows()  {return mysql_affected_rows((MYSQL*) &mysql);}
+  my_ulonglong affected_rows()  {return mysql_affected_rows(static_cast<MYSQL*>
(&mysql));}
   my_ulonglong insert_id () {return mysql_insert_id(&mysql);}
 
   template <class Sequence>
@@ -168,8 +168,7 @@
   while (1) {
 	  MYSQL_ROW d = mysql_fetch_row(result.mysql_result());
 		if (!d) break;
-	  Row row(d,&result,(unsigned int
-	  *)mysql_fetch_lengths(result.mysql_result()),true);
+	  Row row(d,&result,mysql_fetch_lengths(result.mysql_result()),true);
 		if (!row) break;
     seq.push_back(typename Sequence::value_type(row));
 	}
@@ -181,8 +180,7 @@
 	while (1) {
 	  MYSQL_ROW d = mysql_fetch_row(result.mysql_result());	
 		if (!d) return;
-	  Row row(d, &result,
-	  	(unsigned int *)mysql_fetch_lengths(result.mysql_result()),true);
+	  Row row(d, &result, mysql_fetch_lengths(result.mysql_result()),true);
 	  if (!row) break;
     sett.insert(typename Set::value_type(row));
 	}
Index: software/mysql++/lib/custom.pl
diff -u software/mysql++/lib/custom.pl:1.1.1.5 software/mysql++/lib/custom.pl:1.6
--- software/mysql++/lib/custom.pl:1.1.1.5	Fri Feb  4 22:11:20 2005
+++ software/mysql++/lib/custom.pl	Mon Feb  7 00:21:53 2005
@@ -221,7 +221,7 @@
 	$parm_simple2c_b .= ", " unless $j == $i;
 	$defs  .= "    T$j I$j;";
 	$defs  .= "\n" unless $j == $i;
-	$popul .= "    s->I$j = (T$j)row[ O$j ];";
+	$popul .= "    s->I$j = static_cast<T$j>(row[ O$j ]);";
 	$popul .= "\n" unless $j == $i;
         $names .= "    N$j ";
 	$names .= ",\n" unless $j == $i;
@@ -422,7 +422,7 @@
     void set (const Row &row);
     sql_compare_define_##CMP(NAME, $parmC)
     sql_construct_define_##CONTR(NAME, $parmC)
-    static char *names[];
+    static const char *names[];
     static const char *_table;
     static const char *& table() {return _table;}
 
@@ -595,7 +595,7 @@
 					    sql_cmp_type sc) const;
   }; 
 
-  char *NAME::names[] = { 
+  const char *NAME::names[] = { 
 $names 
   }; 
   const char *NAME::_table = #NAME ;  
@@ -761,19 +761,19 @@
 
   template <class Manip>
   inline NAME##_cus_value_list<Manip> 
-  NAME::value_list(cchar *d, Manip m, sql_cmp_type sc) const {
+  NAME::value_list(cchar *d, Manip m, sql_cmp_type /*sc*/) const {
     sql_compare_type_def_##CMP (NAME, value, NUM);
   }
 
   template <class Manip>
   inline NAME##_cus_field_list<Manip> 
-  NAME::field_list(cchar *d, Manip m, sql_cmp_type sc) const {
+  NAME::field_list(cchar *d, Manip m, sql_cmp_type /*sc*/) const {
     sql_compare_type_def_##CMP (NAME, field, NUM);
   }
 
   template <class Manip>
   inline NAME##_cus_equal_list<Manip> 
-  NAME::equal_list(cchar *d, cchar *c, Manip m, sql_cmp_type sc) const {
+  NAME::equal_list(cchar *d, cchar *c, Manip m, sql_cmp_type /*sc*/) const {
     sql_compare_type_defe_##CMP (NAME, equal, NUM);
   }
 
Index: software/mysql++/lib/exceptions.h.in
diff -u software/mysql++/lib/exceptions.h.in:1.1.1.2
software/mysql++/lib/exceptions.h.in:1.2
--- software/mysql++/lib/exceptions.h.in:1.1.1.2	Wed Dec  8 22:18:38 2004
+++ software/mysql++/lib/exceptions.h.in	Sun Feb  6 23:35:38 2005
@@ -99,7 +99,7 @@
 
 #endif
 
-}; // end namespace mysqlpp
+} // end namespace mysqlpp
 
 #endif
 
Index: software/mysql++/lib/manip.cpp
diff -u software/mysql++/lib/manip.cpp:1.1.1.2 software/mysql++/lib/manip.cpp:1.2
--- software/mysql++/lib/manip.cpp:1.1.1.2	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/manip.cpp	Sun Feb  6 17:56:46 2005
@@ -22,7 +22,7 @@
 		else {
 			char *s = new char[in.size() * 2 + 1];
 			mysql_escape_string(s, const_cast < char *>(in.c_str()),
-								(unsigned long) in.size());
+								in.size());
 			SQLString in2 = SQLString("'") + s + "'";
 			in2.processed = true;
 			*p.qparms << in2;
@@ -41,7 +41,7 @@
 {
 	char *s = new char[in.size() * 2 + 1];
 	mysql_escape_string(s, const_cast < char *>(in.c_str()),
-						(unsigned long) in.size());
+						in.size());
 	*o.ostr << "'" << s << "'";
 	delete[] s;
 	return *o.ostr;
@@ -65,7 +65,7 @@
 	if (in.escape_q()) {
 		char *s = new char[in.size() * 2 + 1];
 		mysql_escape_string(s, const_cast<char *>(in.c_str()),
-							(unsigned long)in.size());
+							in.size());
 		if (in.quote_q())
 			*o.ostr << "'" << s << "'";
 		else
@@ -103,7 +103,7 @@
 	if (in.escape_q()) {
 		char *s = new char[in.size() * 2 + 1];
 		mysql_escape_string(s, const_cast < char *>(in.c_str()),
-							(unsigned long) in.size());
+							in.size());
 		if (in.quote_q())
 			o << "'" << s << "'";
 		else
@@ -155,18 +155,18 @@
 	if (in.escape_q()) {
 		char *s = new char[in.size() * 2 + 1];
 		mysql_escape_string(s, const_cast < char *>(in.c_str()),
-							(unsigned long) in.size());
+							in.size());
 		if (in.quote_q())
-			(ostream &) o << "'" << s << "'";
+			static_cast<ostream &>(o) << "'" << s << "'";
 		else
-			(ostream &) o << s;
+			static_cast<ostream &>(o) << s;
 		delete[] s;
 	}
 	else if (in.quote_q()) {
-		(ostream &) o << "'" << in.get_string() << "'";
+		static_cast<ostream &>(o) << "'" << in.get_string() << "'";
 	}
 	else {
-		(ostream &) o << in.get_string();
+		static_cast<ostream &>(o) << in.get_string();
 	}
 	return o;
 }
@@ -183,16 +183,16 @@
 		mysql_escape_string(s, const_cast < char *>(in.c_str()),
 							in.size());
 		if (in.quote_q())
-			(ostream &) o << "'" << s << "'";
+			static_cast<ostream &>(o) << "'" << s << "'";
 		else
-			(ostream &) o << s;
+			static_cast<ostream &>(o) << s;
 		delete[] s;
 	}
 	else if (in.quote_q()) {
-		(ostream &) o << "'" << in.get_string() << "'";
+		static_cast<ostream &>(o) << "'" << in.get_string() << "'";
 	}
 	else {
-		(ostream &) o << in.get_string();
+		static_cast<ostream &>(o) << in.get_string();
 	}
 	return o;
 }
@@ -291,7 +291,7 @@
 		else {
 			char *s = new char[in.size() * 2 + 1];
 			mysql_escape_string(s, const_cast < char *>(in.c_str()),
-								(unsigned long) in.size());
+								in.size());
 			SQLString in2 = s;
 			in2.processed = true;
 			*p.qparms << in2;
@@ -310,7 +310,7 @@
 {
 	char *s = new char[in.size() * 2 + 1];
 	mysql_escape_string(s, const_cast < char *>(in.c_str()),
-						(unsigned long) in.size());
+						in.size());
 	*o.ostr << s;
 	delete[] s;
 	return *o.ostr;
@@ -335,7 +335,7 @@
 	if (in.escape_q()) {
 		char *s = new char[in.size() * 2 + 1];
 		mysql_escape_string(s, const_cast<char*>(in.c_str()),
-				(unsigned long)in.size());
+				in.size());
 		delete[] s;
 	}
 	else {
Index: software/mysql++/lib/manip.h
diff -u software/mysql++/lib/manip.h:1.1.1.4 software/mysql++/lib/manip.h:1.4
--- software/mysql++/lib/manip.h:1.1.1.4	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/manip.h	Mon Feb  7 00:21:53 2005
@@ -30,7 +30,7 @@
   quote_type1(std::ostream *o) : ostr(o) {}
 }; 
 
-inline quote_type1 operator << (std::ostream &o, quote_type0 esc)
+inline quote_type1 operator << (std::ostream &o, quote_type0 /*esc*/)
 {
   return quote_type1(&o);
 }
@@ -41,7 +41,7 @@
   quote_type2(SQLQueryParms *p) : qparms(p) {}
 };
 
-inline quote_type2 operator << (SQLQueryParms &p, quote_type0 esc)
+inline quote_type2 operator << (SQLQueryParms &p, quote_type0 /*esc*/)
 {
   return quote_type2(&p);
 }
@@ -110,7 +110,7 @@
   quote_only_type1(std::ostream *o) : ostr(o) {}
 }; 
 
-inline quote_only_type1 operator << (std::ostream &o, quote_only_type0 esc) {
+inline quote_only_type1 operator << (std::ostream &o, quote_only_type0 /*esc*/)
{
   return quote_only_type1(&o);
 }
 
@@ -119,7 +119,7 @@
   quote_only_type2(SQLQueryParms *p) : qparms(p) {}
 };
 
-inline quote_only_type2 operator << (SQLQueryParms &p, quote_only_type0 esc) {
+inline quote_only_type2 operator << (SQLQueryParms &p, quote_only_type0
/*esc*/) {
   return quote_only_type2(&p);
 }
 
@@ -170,7 +170,7 @@
 }; 
 
 inline quote_double_only_type1 operator << (std::ostream &o,
-					    quote_double_only_type0 esc) {
+					    quote_double_only_type0 /*esc*/) {
   return quote_double_only_type1(&o);
 }
 
@@ -180,7 +180,7 @@
 };
 
 inline quote_double_only_type2 operator << (SQLQueryParms &p, 
-					     quote_double_only_type0 esc) {
+					     quote_double_only_type0 /*esc*/) {
   return quote_double_only_type2(&p);
 }
 
@@ -232,7 +232,7 @@
   escape_type1(std::ostream *o) : ostr(o) {}
 }; 
 
-inline escape_type1 operator << (std::ostream &o, escape_type0 esc) {
+inline escape_type1 operator << (std::ostream &o, escape_type0 /*esc*/) {
   return escape_type1(&o);
 }
 
@@ -241,7 +241,7 @@
   escape_type2(SQLQueryParms *p) : qparms(p) {}
 };
 
-inline escape_type2 operator << (SQLQueryParms &p, escape_type0 esc) {
+inline escape_type2 operator << (SQLQueryParms &p, escape_type0 /*esc*/) {
   return escape_type2(&p);
 }
 
@@ -278,7 +278,7 @@
   do_nothing_type1(std::ostream *o) : ostr(o) {}
 }; 
 
-inline do_nothing_type1 operator << (std::ostream &o, do_nothing_type0 esc) {
+inline do_nothing_type1 operator << (std::ostream &o, do_nothing_type0 /*esc*/)
{
   return do_nothing_type1(&o);
 }
 
@@ -292,7 +292,7 @@
   do_nothing_type2(SQLQueryParms *p) : qparms(p) {}
 };
 
-inline do_nothing_type2 operator << (SQLQueryParms &p, do_nothing_type0 esc) {
+inline do_nothing_type2 operator << (SQLQueryParms &p, do_nothing_type0
/*esc*/) {
   return do_nothing_type2(&p);
 }
 
@@ -308,7 +308,7 @@
   ignore_type2(SQLQueryParms *p) : qparms(p) {}
 };
 
-inline ignore_type2 operator << (SQLQueryParms &p, ignore_type0 esc) {
+inline ignore_type2 operator << (SQLQueryParms &p, ignore_type0 /*esc*/) {
   return ignore_type2(&p);
 }
 
Index: software/mysql++/lib/resiter.h
diff -u software/mysql++/lib/resiter.h:1.1.1.3 software/mysql++/lib/resiter.h:1.4
--- software/mysql++/lib/resiter.h:1.1.1.3	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/resiter.h	Sun Feb  6 17:56:46 2005
@@ -90,7 +90,7 @@
   subscript_iterator  operator - (SizeType n) const
     {subscript_iterator tmp = *this; tmp.i-=n; return tmp;}
   DiffType operator - (const subscript_iterator &j) const
-    {if (d == j.d) return (SizeType)i - j.i; return 0;}
+    {if (d == j.d) return static_cast<SizeType>(i) - j.i; return 0;}
 };
 
 template <class OnType, class ReturnType, class SizeType, class DiffType>
Index: software/mysql++/lib/result.h
diff -u software/mysql++/lib/result.h:1.1.1.5 software/mysql++/lib/result.h:1.4
--- software/mysql++/lib/result.h:1.1.1.5	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/result.h	Sun Feb  6 17:56:46 2005
@@ -42,7 +42,7 @@
 	  if (!mysql_res) {  if (throw_exceptions) throw BadQuery("Results not fetched");
     else return Row();}
     MYSQL_ROW row = mysql_fetch_row(mysql_res);
-    unsigned int* length = (unsigned int*) mysql_fetch_lengths(mysql_res);
+    unsigned long* length = mysql_fetch_lengths(mysql_res);
 	  if (!row || !length) {  if (throw_exceptions) throw BadQuery("Bad row");
     else return Row();}
     return Row(row, this, length, throw_exceptions);
@@ -51,7 +51,7 @@
   //: raw c api function
   bool          eof () const {return mysql_eof(mysql_res) != 0;}
   //: raw c api function
-  long unsigned int *fetch_lengths () const {return mysql_fetch_lengths(mysql_res);}
+  unsigned long *fetch_lengths () const {return mysql_fetch_lengths(mysql_res);}
   //: raw c api function
 
   /* raw mysql c api fields functions */
@@ -155,7 +155,10 @@
   Result () {} //:
   Result (MYSQL_RES *result, bool te = false) 
     : ResUse(result, NULL, te) {mysql = NULL;} //:
-  Result (const Result &other) : ResUse(other) {mysql = NULL;} //:
+  Result (const Result &other)
+	: ResUse(other),
+	const_subscript_container<Result,Row,const Row>() // no copying here
+	{mysql = NULL;} //:
   virtual ~Result() {}  
   // raw mysql c api functions
   const Row fetch_row() const
@@ -163,7 +166,7 @@
 	  if (!mysql_res) {  if (throw_exceptions) throw BadQuery("Results not fetched");
     else return Row();}
     MYSQL_ROW row = mysql_fetch_row(mysql_res);
-    unsigned int* length = (unsigned int*) mysql_fetch_lengths(mysql_res);
+    unsigned long* length = mysql_fetch_lengths(mysql_res);
 	  if (!row || !length) {  if (throw_exceptions) throw BadQuery("Bad row");
     else return Row();}
     return Row(row, this, length, throw_exceptions);
Index: software/mysql++/lib/row.h
diff -u software/mysql++/lib/row.h:1.1.1.5 software/mysql++/lib/row.h:1.5
--- software/mysql++/lib/row.h:1.1.1.5	Fri Jan 14 02:11:31 2005
+++ software/mysql++/lib/row.h	Sun Feb  6 17:56:46 2005
@@ -242,7 +242,7 @@
 
 public:
   Row() {}
-  Row(MYSQL_ROW d, const ResUse *r, unsigned int *jj, bool te = false) 
+  Row(MYSQL_ROW d, const ResUse *r, unsigned long *jj, bool te = false) 
     : res(r), throw_exceptions(te), initialized(false)
 		{
 		  if (!d || !r) {
Index: software/mysql++/lib/sql_query.cpp
diff -u software/mysql++/lib/sql_query.cpp:1.1.1.2 software/mysql++/lib/sql_query.cpp:1.2
--- software/mysql++/lib/sql_query.cpp:1.1.1.2	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/sql_query.cpp	Sun Feb  6 17:56:46 2005
@@ -14,6 +14,8 @@
 Success(q.Success),
 errmsg(q.errmsg),
 def(q.def)
+// these are not copied?
+//,parsed(), parsed_names(), parsed_nums()
 {
 }
 
@@ -48,7 +50,7 @@
 	if (option == 'r' || (option == 'q' && S.is_string)) {
 		char *s = new char[S.size() * 2 + 1];
 		mysql_escape_string(s, const_cast < char *>(S.c_str()),
-							(unsigned long) S.size());
+							S.size());
 		SQLString *ss = new SQLString("'");
 		*ss += s;
 		*ss += "'";
@@ -96,9 +98,9 @@
 		*this << i->before;
 		num = i->num;
 		if (num != -1) {
-			if (num < (int)p.size())
+			if (num < static_cast<int>(p.size()))
 				c = &p;
-			else if (num < (int)def.size())
+			else if (num < static_cast<int>(def.size()))
 				c = &def;
 			else {
 				*this << " ERROR";
@@ -202,9 +204,9 @@
 						s++;
 					}
 
-					if (n >= (long int) parsed_names.size()) {
+					if (n >= static_cast<long int> (parsed_names.size())) {
 						parsed_names.insert(parsed_names.end(),
-								(vector<string>::size_type)(n + 1) -
+								static_cast<vector<string>::size_type>(n + 1) -
 									parsed_names.size(),
 								string());
 					}
Index: software/mysql++/lib/sql_string.cpp
diff -u software/mysql++/lib/sql_string.cpp:1.1.1.1
software/mysql++/lib/sql_string.cpp:1.2
--- software/mysql++/lib/sql_string.cpp:1.1.1.1	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/sql_string.cpp	Sun Feb  6 17:56:46 2005
@@ -33,7 +33,7 @@
 processed(false)
 {
 	char s[6];
-	snprintf(s, sizeof(s), "%dh", (short int)i);
+	snprintf(s, sizeof(s), "%hd", static_cast<short int>(i));
 	*this = s;
 }
 
@@ -43,7 +43,7 @@
 processed(false)
 {
 	char s[6];
-	snprintf(s, sizeof(s), "%uh", (short int)i);
+	snprintf(s, sizeof(s), "%hu", static_cast<short int>(i));
 	*this = s;
 }
 
@@ -53,7 +53,7 @@
 processed(false)
 {
 	char s[6];
-	snprintf(s, sizeof(s), "%dh", i);
+	snprintf(s, sizeof(s), "%hd", i);
 	*this = s;
 }
 
@@ -63,7 +63,7 @@
 processed(false)
 {
 	char s[6];
-	snprintf(s, sizeof(s), "%uh", i);
+	snprintf(s, sizeof(s), "%hu", i);
 	*this = s;
 }
 
@@ -93,7 +93,7 @@
 processed(false)
 {
 	char s[22];
-	snprintf(s, sizeof(s), "%dL", i); 
+	snprintf(s, sizeof(s), "%lld", static_cast<longlong>(i)); 
 	*this = s;
 }
 
@@ -103,7 +103,7 @@
 processed(false) 
 {
 	char s[22];
-	snprintf(s, sizeof(s), "%uL", i);
+	snprintf(s, sizeof(s), "%llu", static_cast<ulonglong>(i));
 	*this = s;
 }
 
Index: software/mysql++/lib/string_util.cpp
diff -u software/mysql++/lib/string_util.cpp:1.1.1.2
software/mysql++/lib/string_util.cpp:1.2
--- software/mysql++/lib/string_util.cpp:1.1.1.2	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/string_util.cpp	Sun Feb  6 17:56:46 2005
@@ -19,7 +19,7 @@
 	j--;
 	for (i = j; i && s[i] == ' '; i--) ;
 	if (i != j) {
-		s.erase(i + 1, (size_t) - 1);
+		s.erase(i + 1, static_cast<size_t> (-1));
 	}
 }
 
Index: software/mysql++/lib/tiny_int.h
diff -u software/mysql++/lib/tiny_int.h:1.1.1.3 software/mysql++/lib/tiny_int.h:1.2
--- software/mysql++/lib/tiny_int.h:1.1.1.3	Fri Dec 17 23:29:43 2004
+++ software/mysql++/lib/tiny_int.h	Sun Feb  6 17:56:46 2005
@@ -8,7 +8,7 @@
 public:
   tiny_int() {}
   tiny_int(short int v) : value(char(v)) {}
-  operator short int() const {return (short int)value;};
+  operator short int() const {return static_cast<short int>(value);};
   tiny_int &operator = (short int v) {value = char(v); return *this;}
   tiny_int &operator += (short int v) {value += char(v); return *this;}
   tiny_int &operator -= (short int v) {value -= char(v); return *this;}


----- End forwarded message -----
Thread
[PATCH] mysql++ and strict compiler warningsChris Frey7 Feb
  • Re: [PATCH] mysql++ and strict compiler warningsWarren Young14 Feb
    • Re: [PATCH] mysql++ and strict compiler warningsChris Frey14 Feb
      • Re: [PATCH] mysql++ and strict compiler warningsWarren Young15 Feb
        • Re: [PATCH] mysql++ and strict compiler warningsChris Frey15 Feb