[glibmm] thread.h: Allow use of this without causing deprecation compiler warnings.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] thread.h: Allow use of this without causing deprecation compiler warnings.
- Date: Wed, 26 Oct 2011 10:35:50 +0000 (UTC)
commit a7588ae238134222cc193488e5447b86550ccf66
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Oct 26 12:33:43 2011 +0200
thread.h: Allow use of this without causing deprecation compiler warnings.
* glib/src/thread.hg: undef and then redefine G_DISABLE_DEPRECATED, and
define GLIB_DISABLE_DEPRECATION_WARNINGS, if G_DISABLE_DEPRECATED is
defined, so we can use the deprecated API in this header (though only in
our own deprecated API).
* tools/generate_wrap_init.pl.in: Include glibmm.h instead of glib.h so
we can include thread.h first (via glibmm.h) instead of only later.
This seems more logical than explicitly including thread.h in all
(even non-glibmm) generated wrap_init.cc files.
* tools/m4/base.m4:
* glib/glibmm.h:
* glib/glibmm/dispatcher.cc:
* glib/glibmm/exceptionhandler.cc:
* glib/glibmm/main.cc:
* examples/thread/thread.cc:
* examples/thread/threadpool.cc: Adjust the includes to include thread.h
first.
ChangeLog | 23 +++++++++++++++++++++++
examples/thread/thread.cc | 2 +-
examples/thread/threadpool.cc | 2 +-
glib/glibmm.h | 6 +++++-
glib/glibmm/dispatcher.cc | 2 +-
glib/glibmm/exceptionhandler.cc | 2 +-
glib/glibmm/main.cc | 4 +++-
glib/src/thread.hg | 27 ++++++++++++++++++++++++++-
tools/generate_wrap_init.pl.in | 2 +-
tools/m4/base.m4 | 3 ++-
10 files changed, 64 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 99ac870..eba6598 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2011-10-26 Murray Cumming <murrayc murrayc com>
+ thread.h: Allow use of this without causing deprecation compiler warnings.
+
+ * glib/src/thread.hg: undef and then redefine G_DISABLE_DEPRECATED, and
+ define GLIB_DISABLE_DEPRECATION_WARNINGS, if G_DISABLE_DEPRECATED is
+ defined, so we can use the deprecated API in this header (though only in
+ our own deprecated API).
+
+ * tools/generate_wrap_init.pl.in: Include glibmm.h instead of glib.h so
+ we can include thread.h first (via glibmm.h) instead of only later.
+ This seems more logical than explicitly including thread.h in all
+ (even non-glibmm) generated wrap_init.cc files.
+
+ * tools/m4/base.m4:
+ * glib/glibmm.h:
+ * glib/glibmm/dispatcher.cc:
+ * glib/glibmm/exceptionhandler.cc:
+ * glib/glibmm/main.cc:
+ * examples/thread/thread.cc:
+ * examples/thread/threadpool.cc: Adjust the includes to include thread.h
+ first.
+
+2011-10-26 Murray Cumming <murrayc murrayc com>
+
Move IOCondition from main.h to iochannel.h and autogenerate it.
* glib/src/iochannel.hg: Use _WRAP_ENUM() for IOCondition instead of
diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc
index d188206..1e26430 100644
--- a/examples/thread/thread.cc
+++ b/examples/thread/thread.cc
@@ -1,8 +1,8 @@
#include <iostream>
#include <queue>
-#include <glibmm/random.h>
#include <glibmm/thread.h>
+#include <glibmm/random.h>
#include <glibmm/timer.h>
diff --git a/examples/thread/threadpool.cc b/examples/thread/threadpool.cc
index 8b36277..542c524 100644
--- a/examples/thread/threadpool.cc
+++ b/examples/thread/threadpool.cc
@@ -1,7 +1,7 @@
#include <iostream>
-#include <glibmm/random.h>
#include <glibmm/thread.h>
+#include <glibmm/random.h>
#include <glibmm/threadpool.h>
#include <glibmm/timer.h>
diff --git a/glib/glibmm.h b/glib/glibmm.h
index 4626fa2..7cc5ad5 100644
--- a/glib/glibmm.h
+++ b/glib/glibmm.h
@@ -81,6 +81,11 @@
#include <glibmmconfig.h>
//#include <glibmm/i18n.h> //This must be included by the application, after system headers such as <iostream>.
+
+//Include this first because we need it to be the first thing to include <glib.h>,
+//so we can do an undef trick to still use deprecated API in the header:
+#include <glibmm/thread.h>
+
#include <glibmm/arrayhandle.h>
#include <glibmm/balancedtree.h>
#include <glibmm/checksum.h>
@@ -122,7 +127,6 @@
#include <glibmm/slisthandle.h>
#include <glibmm/spawn.h>
#include <glibmm/stringutils.h>
-#include <glibmm/thread.h>
#include <glibmm/threadpool.h>
#include <glibmm/timer.h>
#include <glibmm/timeval.h>
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 3a74591..1be104e 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -18,11 +18,11 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <glibmm/thread.h>
#include <glibmm/dispatcher.h>
#include <glibmm/exceptionhandler.h>
#include <glibmm/fileutils.h>
#include <glibmm/main.h>
-#include <glibmm/thread.h>
#include <cerrno>
#include <fcntl.h>
diff --git a/glib/glibmm/exceptionhandler.cc b/glib/glibmm/exceptionhandler.cc
index e9bec1a..79f1a81 100644
--- a/glib/glibmm/exceptionhandler.cc
+++ b/glib/glibmm/exceptionhandler.cc
@@ -20,9 +20,9 @@
*/
#include <glibmmconfig.h>
+#include <glibmm/thread.h>
#include <glibmm/error.h>
#include <glibmm/exceptionhandler.h>
-#include <glibmm/thread.h>
#include <glib.h>
#include <exception>
#include <list>
diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc
index cf19d11..a675ee6 100644
--- a/glib/glibmm/main.cc
+++ b/glib/glibmm/main.cc
@@ -18,10 +18,12 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <glibmm/thread.h>
+
#undef G_DISABLE_DEPRECATED //So we can use newly-deprecated API, to preserve our API.
+
#include <glibmm/main.h>
#include <glibmm/exceptionhandler.h>
-#include <glibmm/thread.h>
#include <glibmm/wrap.h>
#include <glibmm/iochannel.h>
#include <algorithm>
diff --git a/glib/src/thread.hg b/glib/src/thread.hg
index 85e66f2..ed612a7 100644
--- a/glib/src/thread.hg
+++ b/glib/src/thread.hg
@@ -18,10 +18,35 @@
_DEFS(glibmm,glib)
#include <glibmmconfig.h>
+
+// We use GThreadFunctions in the (deprecated) API, so we must temporarily undef G_DISABLE_DEPRECATED.
+// Temporarily undef G_DISABLE_DEPRECATED, redefining it later if appropriate.
+#if defined(G_DISABLE_DEPRECATED) && !defined(GLIBMM_G_DISABLE_DEPRECATED_UNDEFED)
+
+//Stop the deprecation ifdef guards around the API declarations:
+#undef G_DISABLE_DEPRECATED
+
+//Stop the compiler warnings about using the deprecated API;
+#define GLIB_DISABLE_DEPRECATION_WARNINGS 1
+
+#define GLIBMM_G_DISABLE_DEPRECATED_UNDEFED 1
+
+#endif
+
+#include <glib.h>
+
+// Redefine G_DISABLE_DEPRECATED if it was defined before we temporarily undefed it:
+#if defined(GLIBMM_G_DISABLE_DEPRECATED_UNDEFED)
+#define G_DISABLE_DEPRECATED 1
+#undef GLIB_DISABLE_DEPRECATION_WARNINGS
+#undef GLIBMM_G_DISABLE_DEPRECATED_UNDEFED
+#endif
+
+
#include <glibmm/error.h>
#include <glibmm/timeval.h>
#include <sigc++/sigc++.h>
-#include <glib.h>
+
#include <cstddef>
/* Shadow THREAD_PRIORITY_NORMAL macro (from winbase.h).
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 2d409c8..89f9165 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -195,7 +195,7 @@ while ($ARGV[0])
print << "EOF";
-#include <glib.h>
+#include <glibmm.h>
// Disable the 'const' function attribute of the get_type() functions.
// GCC would optimize them out because we don't use the return value.
diff --git a/tools/m4/base.m4 b/tools/m4/base.m4
index 6594aa2..6843125 100644
--- a/tools/m4/base.m4
+++ b/tools/m4/base.m4
@@ -311,11 +311,12 @@ _IMPORT(SECTION_CC_PRE_INCLUDES)
_DEPRECATE_IFDEF_CLASS_START
+#include <glibmm.h>
+
#include <__MODULE__/__FILE__.h>
#include <__MODULE__/private/__FILE__`'_p.h>
_IMPORT(SECTION_CC_INCLUDES)
-#include <glibmm.h>
_IMPORT(SECTION_SRC_CUSTOM)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]