Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Tobler <andreast-list@fgznet.ch>
To: gdb-patches@sourceware.org
Subject: [patch] make static_assert gdb private
Date: Wed, 11 Jan 2012 20:59:00 -0000	[thread overview]
Message-ID: <4F0DF81F.3040905@fgznet.ch> (raw)

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)


             reply	other threads:[~2012-01-11 20:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 20:59 Andreas Tobler [this message]
2012-01-11 21:28 ` Tom Tromey
2012-01-11 21:43   ` Andreas Tobler
2012-01-11 21:46     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F0DF81F.3040905@fgznet.ch \
    --to=andreast-list@fgznet.ch \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox