[patch] make static_assert gdb private

Andreas Tobler andreast-list@fgznet.ch
Wed Jan 11 20:59:00 GMT 2012


Hi all,

I regularly build gdb-cvs on FreeBSD and recently we updated some system 
headers to be C11 'prepared'. Namely assert.h got a definition for 
static_assert.
This gives now a collision when I build gdb-cvs, in mi/mi-common.c where 
we use the static_assert from gdb_assert.h

To workaround I gave a prefix gdb_ to the static_assert from 
gdb_assert.h. This lets me build gdb again.

The C11 static_assert is not FreeBSD only, I found that in the glibc 
repo this static_assert is also defined. So I expect sooner or later 
that GNU/Linux also complains about redefinition of static_assert.

Below is the patch I have in my local tree.

Is this ok for trunk?

Thanks,
Andreas

2012-01-11  Andreas Tobler  <andreast@fgznet.ch>

	* common/gdb_assert.h (gdb_static_assert): Rename static_assert to
	an internal gdb_static_assert.
	* mi/mi-common.c: Rename static_assert to gdb_static_assert.

Index: common/gdb_assert.h
===================================================================
RCS file: /cvs/src/src/gdb/common/gdb_assert.h,v
retrieving revision 1.3
diff -u -r1.3 gdb_assert.h
--- common/gdb_assert.h	4 Jan 2012 08:17:18 -0000	1.3
+++ common/gdb_assert.h	11 Jan 2012 20:51:42 -0000
@@ -22,7 +22,7 @@
  /* A static assertion.  This will cause a compile-time error if EXPR,
     which must be a compile-time constant, is false.  */

-#define static_assert(expr) \
+#define gdb_static_assert(expr) \
    extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]

  /* PRAGMATICS: "gdb_assert.h":gdb_assert() is a lower case (rather
Index: mi/mi-common.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-common.c,v
retrieving revision 1.12
diff -u -r1.12 mi-common.c
--- mi/mi-common.c	4 Jan 2012 08:17:24 -0000	1.12
+++ mi/mi-common.c	11 Jan 2012 20:51:42 -0000
@@ -43,7 +43,7 @@
    NULL
  };

-static_assert (ARRAY_SIZE (async_reason_string_lookup) == 
EXEC_ASYNC_LAST + 1);
+gdb_static_assert (ARRAY_SIZE (async_reason_string_lookup) == 
EXEC_ASYNC_LAST + 1);

  const char *
  async_reason_lookup (enum async_reply_reason reason)



More information about the Gdb-patches mailing list