public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] math.h: Warn about an already-defined log macro
@ 2017-09-04  9:10 Florian Weimer
  2017-09-04 15:45 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2017-09-04  9:10 UTC (permalink / raw)
  To: libc-alpha

This is a common programming error, and the cause of the problem is not
always obvious.

<tgmath.h> defines a log macro, but it includes <math.h> before that, so
that is compatible with the warning.

2017-09-04  Florian Weimer  <fweimer@redhat.com>

	* math/math.h: Issue warning if log is defined.

diff --git a/math/math.h b/math/math.h
index 547b36d10e..6c2ad97fb8 100644
--- a/math/math.h
+++ b/math/math.h
@@ -26,6 +26,11 @@
 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
 #include <bits/libc-header-start.h>
 
+#if defined log && defined __GNUC__
+# warning A macro called log was already defined when <math.h> was included.
+# warning This will cause compilation problems.
+#endif
+
 __BEGIN_DECLS
 
 /* Get definitions of __intmax_t and __uintmax_t.  */

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

* Re: [PATCH] math.h: Warn about an already-defined log macro
  2017-09-04  9:10 [PATCH] math.h: Warn about an already-defined log macro Florian Weimer
@ 2017-09-04 15:45 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2017-09-04 15:45 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Mon, 4 Sep 2017, Florian Weimer wrote:

> This is a common programming error, and the cause of the problem is not
> always obvious.
> 
> <tgmath.h> defines a log macro, but it includes <math.h> before that, so
> that is compatible with the warning.
> 
> 2017-09-04  Florian Weimer  <fweimer@redhat.com>
> 
> 	* math/math.h: Issue warning if log is defined.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2017-09-04 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-04  9:10 [PATCH] math.h: Warn about an already-defined log macro Florian Weimer
2017-09-04 15:45 ` Joseph Myers

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