How to check __builtin_ function is available on gcc
No, you will have to use __GNUC__
and __GNUC_MINOR__
(and __GNUC_PATCHLEVEL__
if you use such gcc versions) to test for each release specific builtin function (gcc releases can be found here)
For example:
/* __builtin_mul_overflow_p added in gcc 7.4 */
#if (__GNUC__ > 7) || \
((__GNUC__ == 7) && (__GNUC_MINOR__ > 3))
#define BUILTIN_MUL_OVERFLOW_EXIST
#endif
#ifdef BUILTIN_MUL_OVERFLOW_EXIST
int c = __builtin_mul_overflow_p (3, 2, 3) ? 0 : 3 * 2;
#endif
And there is an open bug for exactly what you are asking about, in here.