Skip to content

Commit be8754d

Browse files
committed
Add __extension__
1 parent e28e506 commit be8754d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Include/pymacro.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,24 @@
112112
// Implement Py_MIN(), Py_MAX() and Py_ABS() using _Py_TYPEOF() and
113113
// statement expression to only evaluate each argument only once.
114114
// It cannot be used in C++: ISO C++ forbids braced-groups within
115-
// expressions. Statement expression is a GNU extension.
115+
// expressions. Statement expression is a GNU extension. Use __extension__
116+
// to avoid compiler warning in pedantic mode.
116117

117118
/* Minimum value between x and y */
118119
# define Py_MIN(x, y) \
120+
__extension__ \
119121
({ _Py_TYPEOF (x) _x = (x); \
120122
_Py_TYPEOF (y) _y = (y); \
121123
_x < _y ? _x : _y; })
122124
/* Maximum value between x and y */
123125
# define Py_MAX(x, y) \
126+
__extension__ \
124127
({ _Py_TYPEOF (x) _x = (x); \
125128
_Py_TYPEOF (y) _y = (y); \
126129
_x > _y ? _x : _y; })
127130
/* Absolute value of the number x */
128131
# define Py_ABS(x) \
132+
__extension__ \
129133
({ _Py_TYPEOF (x) _x = (x); \
130134
_x < 0 ? -_x : _x; })
131135
#else

0 commit comments

Comments
 (0)