Next: , Up: Integer Properties   [Contents][Index]


17.7.1 Arithmetic Type Properties

TYPE_IS_INTEGER (t) is an arithmetic constant expression that yields 1 if the arithmetic type t is an integer type, 0 otherwise. bool counts as an integer type.

TYPE_SIGNED (t) is an arithmetic constant expression that yields 1 if the real type t is a signed integer type or a floating type, 0 otherwise. If t is an integer type, TYPE_SIGNED (t) is an integer constant expression.

EXPR_SIGNED (e) yields 1 if the real expression e has a signed integer type or a floating type, 0 otherwise. If e is an integer constant expression or an arithmetic constant expression, EXPR_SIGNED (e) is likewise. The expression e is not evaluated, and EXPR_SIGNED (e) is typically optimized to a constant.

Example usage:

#include <intprops.h>
#include <sys/types.h>

enum
{
  clock_t_is_integer = TYPE_IS_INTEGER (clock_t),
  uid_t_is_signed = TYPE_SIGNED (uid_t)
};

int
CLOCKS_PER_SEC_is_signed (void)
{
  return EXPR_SIGNED (CLOCKS_PER_SEC);
}