diff mbox series

math.h: Warn about an already-defined log macro

Message ID 20170904090959.276DE439942E3@oldenburg.str.redhat.com
State New
Headers show
Series math.h: Warn about an already-defined log macro | expand

Commit Message

Florian Weimer Sept. 4, 2017, 9:09 a.m. UTC
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.

Comments

Joseph Myers Sept. 4, 2017, 3:44 p.m. UTC | #1
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.
diff mbox series

Patch

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.  */