Query: __builtin_constant_p
OS: netbsd
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
__BUILTIN_CONSTANT_P(3) BSD Library Functions Manual __BUILTIN_CONSTANT_P(3)NAME__builtin_constant_p -- GNU extension to determine compile time constantsSYNOPSISint __builtin_constant_p(value);DESCRIPTIONThe __builtin_constant_p() is a GNU extension for determining whether a value is known to be constant at compile time. The function is closely related to the concept of ``constant folding'' used by modern optimizing compilers. If the value is known to be a compile-time constant, a value 1 is returned. If __builtin_constant_p() returns 0, the value is not a compile- time constant in the sense that gcc(1) was unable to determine whether the value is constant or not.EXAMPLESA typical example of the use of __builtin_constant_p() involves a situation where it may be desirable to fold the computation if it involves a constant, but a function call is needed otherwise. For instance, bswap16(3) is defined in NetBSD as: #define bswap16(x) (__builtin_constant_p((x)) ? __byte_swap_u16_constant(x) : __BYTE_SWAP_U16_VARIABLE(x))SEE ALSOgcc(1), __builtin_object_size(3), __builtin_return_address(3)CAVEATSThis is a non-standard, compiler-specific extension.BSDDecember 19, 2010 BSD