List:MySQL++« Previous MessageNext Message »
From:Chris Frey Date:December 16 2004 6:59pm
Subject:[patch] #include "file.h" instead of <file.h>
View as plain text  
Hi,

New versions of mysql++ have the new header names, but somewhere along the line,
they also changed from #include "file.h" to #include <file.h>

This causes problems when names in different and libraries conflict with ones
from mysql++ (such as connection.h).  Since #include <file.h> searches the
include path, this makes the build process brittle, since compilation
success depends on the order of the -I command line options.

The #include "file.h" style searches the current directory (i.e. even
the "current directory" of an installed mysql++ in /usr/include/mysql++).
So doing #include "connection.h" from within mysql++.h will find the
correct file in /usr/include/mysql++ under normal circumstances.

I've found this #include behaviour to be consistent on Linux and Windows
(with VC7), and make it a policy to use #include <file.h> when including
accross a project/library boundary, and #include "file.h" when including
within a project.

A quick grep of various headers in /usr/include indicates that it is normal
practice to use #include "file.h" for including sub-headers within the
same project.  Even mysql's C API uses this technique.

Therefore, here is a patch to fix mysql++-1.7.25 to use #include "file.h"
where appropriate. :-)

- Chris



diff -ru mysql++-1.7.25/lib/coldata.h mysql++-1.7.25-cdf/lib/coldata.h
--- mysql++-1.7.25/lib/coldata.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/coldata.h	2004-12-16 13:21:28.000000000 -0500
@@ -1,15 +1,15 @@
 #ifndef MYSQLPP_COLDATA_H
 #define MYSQLPP_COLDATA_H
 
-#include <platform.h>
+#include "platform.h"
 
-#include <const_string.h>
-#include <convert.h>
-#include <defs.h>
-#include <exceptions.h>
-#include <null.h>
-#include <string_util.h>
-#include <type_info.h>
+#include "const_string.h"
+#include "convert.h"
+#include "defs.h"
+#include "exceptions.h"
+#include "null.h"
+#include "string_util.h"
+#include "type_info.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/compare.h mysql++-1.7.25-cdf/lib/compare.h
--- mysql++-1.7.25/lib/compare.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/compare.h	2004-12-16 13:21:35.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_COMPARE_H
 #define MYSQLPP_COMPARE_H
 
-#include <row.h>
+#include "row.h"
 
 #include <cstring>
 #include <functional>
diff -ru mysql++-1.7.25/lib/connection.h mysql++-1.7.25-cdf/lib/connection.h
--- mysql++-1.7.25/lib/connection.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/connection.h	2004-12-16 13:21:59.000000000 -0500
@@ -1,10 +1,10 @@
 #ifndef MYSQLPP_CONNECTION_H
 #define MYSQLPP_CONNECTION_H
 
-#include <platform.h>
+#include "platform.h"
 
-#include <exceptions.h>
-#include <result.h>
+#include "exceptions.h"
+#include "result.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/const_string.h mysql++-1.7.25-cdf/lib/const_string.h
--- mysql++-1.7.25/lib/const_string.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/const_string.h	2004-12-16 13:22:05.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_CONST_STRING_H
 #define MYSQLPP_CONST_STRING_H
 
-#include <defs.h>
+#include "defs.h"
 
 #include <stdexcept>
 #include <string>
diff -ru mysql++-1.7.25/lib/convert.h mysql++-1.7.25-cdf/lib/convert.h
--- mysql++-1.7.25/lib/convert.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/convert.h	2004-12-16 13:22:14.000000000 -0500
@@ -1,9 +1,9 @@
 #ifndef MYSQLPP_CONVERT_H
 #define MYSQLPP_CONVERT_H
 
-#include <platform.h>
+#include "platform.h"
 
-#include <defs.h>
+#include "defs.h"
 
 #include <stdlib.h>
 
diff -ru mysql++-1.7.25/lib/custom.h mysql++-1.7.25-cdf/lib/custom.h
--- mysql++-1.7.25/lib/custom.h	2004-12-09 23:19:02.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/custom.h	2004-12-16 13:22:37.000000000 -0500
@@ -5,8 +5,8 @@
 #ifndef MYSQLPP_CUSTOM_H
 #define MYSQLPP_CUSTOM_H
 
-#include <defs.h>
-#include <tiny_int.h>
+#include "defs.h"
+#include "tiny_int.h"
 
 #include <string>
 
diff -ru mysql++-1.7.25/lib/datetime.h mysql++-1.7.25-cdf/lib/datetime.h
--- mysql++-1.7.25/lib/datetime.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/datetime.h	2004-12-16 13:23:14.000000000 -0500
@@ -1,11 +1,11 @@
 #ifndef MYSQLPP_DATETIME_H
 #define MYSQLPP_DATETIME_H
 
-#include <defs.h>
+#include "defs.h"
 
-#include <coldata.h>
-#include <stream2string.h>
-#include <tiny_int.h>
+#include "coldata.h"
+#include "stream2string.h"
+#include "tiny_int.h"
 
 #include <string>
 #include <sstream>
diff -ru mysql++-1.7.25/lib/defs.h mysql++-1.7.25-cdf/lib/defs.h
--- mysql++-1.7.25/lib/defs.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/defs.h	2004-12-16 13:23:22.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_DEFS_H
 #define MYSQLPP_DEFS_H
 
-#include <platform.h>
+#include "platform.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/field_names.h mysql++-1.7.25-cdf/lib/field_names.h
--- mysql++-1.7.25/lib/field_names.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/field_names.h	2004-12-16 13:23:41.000000000 -0500
@@ -1,8 +1,8 @@
 #ifndef MYSQLPP_FIELD_NAMES_H
 #define MYSQLPP_FIELD_NAMES_H
 
-#include <coldata.h>
-#include <string_util.h>
+#include "coldata.h"
+#include "string_util.h"
 
 #include <algorithm>
 #include <vector>
diff -ru mysql++-1.7.25/lib/fields.h mysql++-1.7.25-cdf/lib/fields.h
--- mysql++-1.7.25/lib/fields.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/fields.h	2004-12-16 13:23:47.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_FIELDS_H
 #define MYSQLPP_FIELDS_H
 
-#include <resiter.h>
+#include "resiter.h"
 
 namespace mysqlpp {
 
diff -ru mysql++-1.7.25/lib/field_types.h mysql++-1.7.25-cdf/lib/field_types.h
--- mysql++-1.7.25/lib/field_types.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/field_types.h	2004-12-16 13:23:56.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_FIELD_TYPES_H
 #define MYSQLPP_FIELD_TYPES_H
 
-#include <type_info.h>
+#include "type_info.h"
 
 #include <vector>
 
diff -ru mysql++-1.7.25/lib/manip.h mysql++-1.7.25-cdf/lib/manip.h
--- mysql++-1.7.25/lib/manip.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/manip.h	2004-12-16 13:24:16.000000000 -0500
@@ -1,12 +1,12 @@
 #ifndef MYSQLPP_MANIP_H
 #define MYSQLPP_MANIP_H
 
-#include <defs.h>
+#include "defs.h"
 
-#include <datetime.h>
-#include <myset.h>
-#include <sql_string.h>
-#include <sql_query.h>
+#include "datetime.h"
+#include "myset.h"
+#include "sql_string.h"
+#include "sql_query.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/myset.h mysql++-1.7.25-cdf/lib/myset.h
--- mysql++-1.7.25/lib/myset.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/myset.h	2004-12-16 13:24:30.000000000 -0500
@@ -1,10 +1,10 @@
 #ifndef MYSQLPP_MYSET_H
 #define MYSQLPP_MYSET_H
 
-#include <defs.h>
+#include "defs.h"
 
-#include <coldata.h>
-#include <stream2string.h>
+#include "coldata.h"
+#include "stream2string.h"
 
 #include <iostream>
 #include <set>
diff -ru mysql++-1.7.25/lib/mysql++.h mysql++-1.7.25-cdf/lib/mysql++.h
--- mysql++-1.7.25/lib/mysql++.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/mysql++.h	2004-12-16 13:25:01.000000000 -0500
@@ -1,28 +1,28 @@
-#include <platform.h>
+#include "platform.h"
 
-#include <defs.h>
+#include "defs.h"
 
-#include <coldata.h>
-#include <compare.h>
-#include <connection.h>
-#include <const_string.h>
-#include <convert.h>
-#include <datetime.h>
-#include <exceptions.h>
-#include <field_names.h>
-#include <field_types.h>
-#include <fields.h>
-#include <manip.h>
-#include <myset.h>
-#include <null.h>
-#include <query.h>
-#include <resiter.h>
-#include <result.h>
-#include <row.h>
-#include <sql_query.h>
-#include <sql_string.h>
-#include <stream2string.h>
-#include <tiny_int.h>
-#include <type_info.h>
-#include <vallist.h>
+#include "coldata.h"
+#include "compare.h"
+#include "connection.h"
+#include "const_string.h"
+#include "convert.h"
+#include "datetime.h"
+#include "exceptions.h"
+#include "field_names.h"
+#include "field_types.h"
+#include "fields.h"
+#include "manip.h"
+#include "myset.h"
+#include "null.h"
+#include "query.h"
+#include "resiter.h"
+#include "result.h"
+#include "row.h"
+#include "sql_query.h"
+#include "sql_string.h"
+#include "stream2string.h"
+#include "tiny_int.h"
+#include "type_info.h"
+#include "vallist.h"
 
diff -ru mysql++-1.7.25/lib/mysql++.hh mysql++-1.7.25-cdf/lib/mysql++.hh
--- mysql++-1.7.25/lib/mysql++.hh	2004-11-17 21:04:41.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/mysql++.hh	2004-12-16 13:29:36.000000000 -0500
@@ -1,3 +1,3 @@
 #warning This header is obsolete. Please use mysql++.h instead.
 using namespace mysqlpp;
-#include <mysql++.h>
+#include "mysql++.h"
diff -ru mysql++-1.7.25/lib/null.h mysql++-1.7.25-cdf/lib/null.h
--- mysql++-1.7.25/lib/null.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/null.h	2004-12-16 13:25:32.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_NULL_H
 #define MYSQLPP_NULL_H
 
-#include <exceptions.h>
+#include "exceptions.h"
 
 #include <ostream>
 
diff -ru mysql++-1.7.25/lib/query.h mysql++-1.7.25-cdf/lib/query.h
--- mysql++-1.7.25/lib/query.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/query.h	2004-12-16 13:26:38.000000000 -0500
@@ -1,12 +1,12 @@
 #ifndef MYSQLPP_QUERY_H
 #define MYSQLPP_QUERY_H
 
-#include <defs.h>
+#include "defs.h"
 
-#include <coldata.h>
-#include <connection.h>
-#include <result.h>
-#include <sql_query.h>
+#include "coldata.h"
+#include "connection.h"
+#include "result.h"
+#include "sql_query.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/resiter.h mysql++-1.7.25-cdf/lib/resiter.h
--- mysql++-1.7.25/lib/resiter.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/resiter.h	2004-12-16 13:26:55.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_RESITER_H
 #define MYSQLPP_RESITER_H
 
-#include <defs.h>
+#include "defs.h"
 
 #include <iterator>
 
diff -ru mysql++-1.7.25/lib/result.h mysql++-1.7.25-cdf/lib/result.h
--- mysql++-1.7.25/lib/result.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/result.h	2004-12-16 13:27:18.000000000 -0500
@@ -1,14 +1,14 @@
 #ifndef MYSQLPP_RESULT_H
 #define MYSQLPP_RESULT_H
 
-#include <defs.h>
+#include "defs.h"
 
-#include <exceptions.h>
-#include <fields.h>
-#include <field_names.h>
-#include <field_types.h>
-#include <resiter.h>
-#include <row.h>
+#include "exceptions.h"
+#include "fields.h"
+#include "field_names.h"
+#include "field_types.h"
+#include "resiter.h"
+#include "row.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/row.h mysql++-1.7.25-cdf/lib/row.h
--- mysql++-1.7.25/lib/row.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/row.h	2004-12-16 13:27:28.000000000 -0500
@@ -1,10 +1,10 @@
 #ifndef MYSQLPP_ROW_H
 #define MYSQLPP_ROW_H
 
-#include <coldata.h>
-#include <exceptions.h>
-#include <resiter.h>
-#include <vallist.h>
+#include "coldata.h"
+#include "exceptions.h"
+#include "resiter.h"
+#include "vallist.h"
 
 #include <vector>
 #include <string>
diff -ru mysql++-1.7.25/lib/sqlplus.hh mysql++-1.7.25-cdf/lib/sqlplus.hh
--- mysql++-1.7.25/lib/sqlplus.hh	2004-11-17 21:04:41.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/sqlplus.hh	2004-12-16 13:29:44.000000000 -0500
@@ -1,3 +1,3 @@
 #warning This header is obsolete. Please use mysql++.h instead.
 using namespace mysqlpp;
-#include <mysql++.h>
+#include "mysql++.h"
diff -ru mysql++-1.7.25/lib/sql_query.h mysql++-1.7.25-cdf/lib/sql_query.h
--- mysql++-1.7.25/lib/sql_query.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/sql_query.h	2004-12-16 13:27:58.000000000 -0500
@@ -1,11 +1,11 @@
 #ifndef MYSQLPP_SQL_QUERY_H
 #define MYSQLPP_SQL_QUERY_H
 
-#include <defs.h>
+#include "defs.h"
 
-#include <custom.h>
-#include <sql_string.h>
-#include <tiny_int.h>
+#include "custom.h"
+#include "sql_string.h"
+#include "tiny_int.h"
 
 #include <sstream>
 #include <vector>
diff -ru mysql++-1.7.25/lib/sql_string.h mysql++-1.7.25-cdf/lib/sql_string.h
--- mysql++-1.7.25/lib/sql_string.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/sql_string.h	2004-12-16 13:28:05.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_SQL_STRING_H
 #define MYSQLPP_SQL_STRING_H
 
-#include <defs.h>
+#include "defs.h"
 
 #include <stdio.h>
 #include <string>
diff -ru mysql++-1.7.25/lib/string_util.h mysql++-1.7.25-cdf/lib/string_util.h
--- mysql++-1.7.25/lib/string_util.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/string_util.h	2004-12-16 13:28:15.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_STRING_UTIL_H
 #define MYSQLPP_STRING_UTIL_H
 
-#include <defs.h>
+#include "defs.h"
 
 #include <ctype.h>
 
diff -ru mysql++-1.7.25/lib/type_info.h mysql++-1.7.25-cdf/lib/type_info.h
--- mysql++-1.7.25/lib/type_info.h	2004-12-09 23:18:05.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/type_info.h	2004-12-16 13:28:42.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_TYPE_INFO_H
 #define MYSQLPP_TYPE_INFO_H
 
-#include <defs.h>
+#include "defs.h"
 
 #include <mysql.h>
 
diff -ru mysql++-1.7.25/lib/vallist.h mysql++-1.7.25-cdf/lib/vallist.h
--- mysql++-1.7.25/lib/vallist.h	2004-12-08 22:03:50.000000000 -0500
+++ mysql++-1.7.25-cdf/lib/vallist.h	2004-12-16 13:29:05.000000000 -0500
@@ -1,7 +1,7 @@
 #ifndef MYSQLPP_VALLIST_H
 #define MYSQLPP_VALLIST_H
 
-#include <manip.h>
+#include "manip.h"
 
 #include <string>
 #include <vector>

Thread
[patch] #include "file.h" instead of <file.h>Chris Frey16 Dec
  • Re: [patch] #include "file.h" instead of <file.h>Warren Young16 Dec
    • Re: [patch] #include "file.h" instead of <file.h>Chris Frey17 Dec
      • Re: [patch] #include "file.h" instead of <file.h>Warren Young17 Dec