ax_gcc_func_attribute

Synopsis

AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)

Description

This macro checks if the compiler supports one of GCC’s function attributes; many other compilers also provide function attributes with the same syntax. Compiler warnings are used to detect supported attributes as unsupported ones are ignored by default so quieting warnings when using this macro will yield false positives.

The ATTRIBUTE parameter holds the name of the attribute to be checked.

If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.

The macro caches its result in the ax_cv_have_func_attribute_<attribute> variable.

The macro currently supports the following function attributes:

 alias
 aligned
 alloc_size
 always_inline
 artificial
 cold
 const
 constructor
 constructor_priority for constructor attribute with priority
 deprecated
 destructor
 dllexport
 dllimport
 error
 externally_visible
 fallthrough
 flatten
 format
 format_arg
 gnu_format
 gnu_inline
 hot
 ifunc
 leaf
 malloc
 noclone
 noinline
 nonnull
 noreturn
 nothrow
 optimize
 pure
 sentinel
 sentinel_position
 unused
 used
 visibility
 warning
 warn_unused_result
 weak
 weakref

Unsupported function attributes will be tested with a prototype returning an int and not accepting any arguments and the result of the check might be wrong or meaningless so use with care.

Source Code

Download the latest version of ax_gcc_func_attribute.m4 or browse the macro’s revision history.

License

Copyright © 2013 Gabriele Svelto 

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.