__BUILTIN_CONSTANT_P(3)
π NAME β __builtin_constant_p(3) π
okay so hey bestie π, you're in the Library Functions Manual, and the queen of this page is __builtin_constant_p β a GNU extension to determine compile time constants β¨. That's literally the whole vibe.
π¦ SYNOPSIS π¦
int
__builtin_constant_p(value);
π DESCRIPTION π
Okay so __builtin_constant_p() is a GNU extension for determining whether a value is known to be constant at compile time π§. It's 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 π. Periodt.
πΈ EXAMPLES πΈ
A 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 ALSO π
β οΈ CAVEATS β οΈ
bestie, this is a non-standard, compiler-specific extension π. That's the caveat, no cap.
source: Debian π β this page is dated December 19, 2010 π. stay iconic, bestie π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 Jukka Ruohonen <jruohonen@iki.fi>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms