diff --git a/autoconf/ast_gcc_attribute.m4 b/autoconf/ast_gcc_attribute.m4
index 4ade81404a4bf3f3f845599fed69748897924541..b1972bedf38ecf5dd77fafb6004c3eab67b76060 100644
--- a/autoconf/ast_gcc_attribute.m4
+++ b/autoconf/ast_gcc_attribute.m4
@@ -7,6 +7,7 @@ AC_MSG_CHECKING(for compiler 'attribute $1' support)
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 m4_ifval([$4],$4=0)
+ax_cv_have_func_attribute_$1=0
 
 if test "x$2" = "x"
 then
@@ -15,6 +16,7 @@ AC_COMPILE_IFELSE(
 			[])],
 	AC_MSG_RESULT(yes)
 	m4_ifval([$4],$4=1)
+	ax_cv_have_func_attribute_$1=1
 	AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
 	AC_MSG_RESULT(no)
 )
@@ -24,6 +26,7 @@ AC_COMPILE_IFELSE(
 			[])],
 	AC_MSG_RESULT(yes)
 	m4_ifval([$4],$4=1)
+	ax_cv_have_func_attribute_$1=1
 	AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
 	AC_MSG_RESULT(no)
 )
diff --git a/configure b/configure
index 9a8fb403cae4ed7bd7220c1fd0b285f72c67f26c..70553fcdfaad9857b5bc0aaccd1d2afae17d3d87 100755
--- a/configure
+++ b/configure
@@ -18139,6 +18139,7 @@ $as_echo_n "checking for compiler 'attribute pure' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_pure=0
 
 if test "x" = "x"
 then
@@ -18157,6 +18158,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_pure=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_pure 1
@@ -18184,6 +18186,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_pure=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_pure 1
@@ -18207,6 +18210,7 @@ $as_echo_n "checking for compiler 'attribute malloc' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_malloc=0
 
 if test "x" = "x"
 then
@@ -18225,6 +18229,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_malloc=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_malloc 1
@@ -18252,6 +18257,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_malloc=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_malloc 1
@@ -18275,6 +18281,7 @@ $as_echo_n "checking for compiler 'attribute const' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_const=0
 
 if test "x" = "x"
 then
@@ -18293,6 +18300,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_const=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_const 1
@@ -18320,6 +18328,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_const=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_const 1
@@ -18343,6 +18352,7 @@ $as_echo_n "checking for compiler 'attribute unused' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_unused=0
 
 if test "x" = "x"
 then
@@ -18361,6 +18371,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_unused=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_unused 1
@@ -18388,6 +18399,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_unused=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_unused 1
@@ -18411,6 +18423,7 @@ $as_echo_n "checking for compiler 'attribute always_inline' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_always_inline=0
 
 if test "x" = "x"
 then
@@ -18429,6 +18442,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_always_inline=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_always_inline 1
@@ -18456,6 +18470,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_always_inline=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_always_inline 1
@@ -18479,6 +18494,7 @@ $as_echo_n "checking for compiler 'attribute deprecated' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_deprecated=0
 
 if test "x" = "x"
 then
@@ -18497,6 +18513,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_deprecated=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_deprecated 1
@@ -18524,6 +18541,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_deprecated=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_deprecated 1
@@ -18547,6 +18565,7 @@ $as_echo_n "checking for compiler 'attribute sentinel' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_sentinel=0
 
 if test "x" = "x"
 then
@@ -18565,6 +18584,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_sentinel=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_sentinel 1
@@ -18592,6 +18612,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_sentinel=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_sentinel 1
@@ -18615,6 +18636,7 @@ $as_echo_n "checking for compiler 'attribute warn_unused_result' support... " >&
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_warn_unused_result=0
 
 if test "x" = "x"
 then
@@ -18633,6 +18655,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_warn_unused_result=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_warn_unused_result 1
@@ -18660,6 +18683,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_warn_unused_result=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_warn_unused_result 1
@@ -18683,6 +18707,7 @@ $as_echo_n "checking for compiler 'attribute may_alias' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_may_alias=0
 
 if test "x" = "x"
 then
@@ -18701,6 +18726,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_may_alias=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_may_alias 1
@@ -18728,6 +18754,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_may_alias=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_may_alias 1
@@ -18751,6 +18778,7 @@ $as_echo_n "checking for compiler 'attribute constructor' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_constructor=0
 
 if test "x" = "x"
 then
@@ -18769,6 +18797,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_constructor=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_constructor 1
@@ -18796,6 +18825,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_constructor=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_constructor 1
@@ -18813,12 +18843,17 @@ fi
 CFLAGS="$saved_CFLAGS"
 
 
+if test "$ax_cv_have_func_attribute_constructor" != "1"; then
+	as_fn_error $? "*** Function constructor attribute is not supported by your compiler." "$LINENO" 5
+fi
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler 'attribute destructor' support" >&5
 $as_echo_n "checking for compiler 'attribute destructor' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_destructor=0
 
 if test "x" = "x"
 then
@@ -18837,6 +18872,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_destructor=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_destructor 1
@@ -18864,6 +18900,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_destructor=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_destructor 1
@@ -18881,12 +18918,16 @@ fi
 CFLAGS="$saved_CFLAGS"
 
 
+if test "$ax_cv_have_func_attribute_destructor" != "1"; then
+	as_fn_error $? "*** Function destructor attribute is not supported by your compiler." "$LINENO" 5
+fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler 'attribute noreturn' support" >&5
 $as_echo_n "checking for compiler 'attribute noreturn' support... " >&6; }
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_noreturn=0
 
 if test "xnoreturn" = "x"
 then
@@ -18905,6 +18946,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_noreturn=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_noreturn 1
@@ -18932,6 +18974,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
 
+	ax_cv_have_func_attribute_noreturn=1
 
 cat >>confdefs.h <<_ACEOF
 #define HAVE_ATTRIBUTE_noreturn 1
diff --git a/configure.ac b/configure.ac
index 23ff5265a9a61fd3c74214178da4d9e3bcb2d8e2..f5c160c739071d105bc2789ab64e20cf6bd53e47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1149,7 +1149,14 @@ AST_GCC_ATTRIBUTE(sentinel)
 AST_GCC_ATTRIBUTE(warn_unused_result)
 AST_GCC_ATTRIBUTE(may_alias)
 AST_GCC_ATTRIBUTE(constructor)
+if test "$ax_cv_have_func_attribute_constructor" != "1"; then
+	AC_MSG_ERROR([*** Function constructor attribute is not supported by your compiler.])
+fi
+
 AST_GCC_ATTRIBUTE(destructor)
+if test "$ax_cv_have_func_attribute_destructor" != "1"; then
+	AC_MSG_ERROR([*** Function destructor attribute is not supported by your compiler.])
+fi
 AST_GCC_ATTRIBUTE(noreturn,noreturn)
 
 AC_MSG_CHECKING(for -fsanitize=address support)
diff --git a/include/asterisk/optional_api.h b/include/asterisk/optional_api.h
index 1118dc7cda18132f875f1f5b6e832e1ffb1a9a19..1ac765162416c941dc44ec5e22f79f01ecad028f 100644
--- a/include/asterisk/optional_api.h
+++ b/include/asterisk/optional_api.h
@@ -107,10 +107,6 @@
 
 #if defined(OPTIONAL_API)
 
-#if !defined(HAVE_ATTRIBUTE_constructor) || !defined(HAVE_ATTRIBUTE_constructor)
-#error OPTIONAL_API requires compiler constructor/destructor support
-#endif
-
 /*!
  * \internal
  * \brief Function pointer to an optional API function.