added G_PASTE() and G_STATIC_ASSERT(), based on patches by Christian

2008-10-29 16:11:14  Tim Janik  <timj@gtk.org>

        * glib/gmacros.h: added G_PASTE() and G_STATIC_ASSERT(), based on
        patches by Christian Persch and Christian Dywan. Fixes:
        Bug 558381 - Add support for compile time assertions


svn path=/trunk/; revision=7633
This commit is contained in:
16:11:14 Tim Janik 2008-10-29 15:14:06 +00:00 committed by Tim Janik
parent e8bb63a7db
commit 0ffa76b9e9
2 changed files with 10 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2008-10-29 16:11:14 Tim Janik <timj@gtk.org>
* glib/gmacros.h: added G_PASTE() and G_STATIC_ASSERT(), based on
patches by Christian Persch and Christian Dywan. Fixes:
Bug 558381 - Add support for compile time assertions
2008-10-27 Joseph Pingenot <gnomesvn@digitasaru.net> 2008-10-27 Joseph Pingenot <gnomesvn@digitasaru.net>
* glib/ghash.c: changed "#GHashTableIterator" to "#GHashTableIter" * glib/ghash.c: changed "#GHashTableIterator" to "#GHashTableIter"

View File

@ -137,6 +137,10 @@
#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) #define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string)
#define G_STRINGIFY_ARG(contents) #contents #define G_STRINGIFY_ARG(contents) #contents
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
#define G_STATIC_ASSERT(expr) typedef struct { char Compile_Time_Assertion[(expr) ? 1 : -1]; } G_PASTE (_GStaticAssert_, __LINE__)
/* Provide a string identifying the current code position */ /* Provide a string identifying the current code position */
#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus) #if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus)
# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()" # define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()"