HP aC++/HP C A.06.20 Programmer's Guide

attribute noreturn
__attribute__ ((noreturn))
Similar to the NO_RETURN pragma, this attribute asserts to the optimizer that this
function never returns to the call site. This allows the optimizer to delete any code after
the function call. A C++ function marked with this attribute may still throw an exception
unless it has an empty throw list.
Example:
void foo(int i) __attribute__ ((noreturn));
attribute format
__attribute__ ((format(type, arg_format_string,
arg_check_start)))
The format attribute specifies that a function takes printf, scanf, strftime or
strfmon style arguments which should be type-checked against a format string. In
the example above, the format string is the second argument of the function foo and
the arguments to check start with the third argument.
Example:
int foo(int i, const char *my_format, ...) __attribute__((format(printf, 2, 3)));
attribute visibility
__attribute__ ((visibility("default"|"protected"|"hidden")))
The visibility attributes "default", "protected", and "hidden", are equivalent
to the options -Bdefault, -Bprotected, and -Bhidden, and the pragmas
DEFAULT_BINDING, EXTERN, and HIDDEN, respectively.
Example:
void foo(int i) __attribute__ ((visibility("hidden"));
attribute warn_unused_result
__attribute__ ((warn_unused_result))
If a caller of a function with this attribute does not use its return value, the compiler
emits a warning. This is useful for functions where not checking the result can be a
security problem or always a program bug, as with realloc. The following example
results in a warning on line 5:
int fn () __attribute__ ((warn_unused_result));
int test()
{
if (fn () < 0) return -1;
fn ();
return 0;
}
152 Pragma Directives and Attributes