public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] make static_assert gdb private
@ 2012-01-11 20:59 Andreas Tobler
  2012-01-11 21:28 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Tobler @ 2012-01-11 20:59 UTC (permalink / raw)
  To: gdb-patches

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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] make static_assert gdb private
  2012-01-11 20:59 [patch] make static_assert gdb private Andreas Tobler
@ 2012-01-11 21:28 ` Tom Tromey
  2012-01-11 21:43   ` Andreas Tobler
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2012-01-11 21:28 UTC (permalink / raw)
  To: Andreas Tobler; +Cc: gdb-patches

>>>>> "Andreas" == Andreas Tobler <andreast-list@fgznet.ch> writes:

Andreas> Is this ok for trunk?

Ok.  Thanks.

BTW your patch got word-wrapped.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] make static_assert gdb private
  2012-01-11 21:28 ` Tom Tromey
@ 2012-01-11 21:43   ` Andreas Tobler
  2012-01-11 21:46     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Tobler @ 2012-01-11 21:43 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 11.01.12 22:15, Tom Tromey wrote:
>>>>>> "Andreas" == Andreas Tobler<andreast-list@fgznet.ch>  writes:
>
> Andreas>  Is this ok for trunk?
>
> Ok.  Thanks.

Thank you!

> BTW your patch got word-wrapped.

That's me being a c&p man. I copied the diff from the terminal into 
thunderbird. The real diff looks a bit ugly since I overrun the 80 chars 
per line.

Here I have a question about formatting, would the below be better?

-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);


Andreas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] make static_assert gdb private
  2012-01-11 21:43   ` Andreas Tobler
@ 2012-01-11 21:46     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2012-01-11 21:46 UTC (permalink / raw)
  To: Andreas Tobler; +Cc: gdb-patches

>>>>> "Andreas" == Andreas Tobler <andreast-list@fgznet.ch> writes:

Andreas> Here I have a question about formatting, would the below be better?

Yeah, I think so.
Thanks again.

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

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-11 21:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-11 20:59 [patch] make static_assert gdb private Andreas Tobler
2012-01-11 21:28 ` Tom Tromey
2012-01-11 21:43   ` Andreas Tobler
2012-01-11 21:46     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).