controlled compile-time specialization

Andreas Schwab schwab@linux-m68k.org
Sun Dec 14 14:10:36 GMT 2025


On Dez 14 2025, Martin Uecker via Gcc wrote:

> One could use templates in C++ or macros, but then this is
> rather heavy weight and also rigid as one has to structure the
> code around it.   I am rather looking for some lightweight 
> solution such as annotation I could put on the argument or variable
> that says: If this is value is known to be a compile-time
> constant, please create a specialized code path when optimizing.
> (maybe with some limit on recursion), maybe only for specified
> parameter ranges.
>
> Or are there other better ways to do this already?

Is __builtin_constant_p what you are looking for?

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


More information about the Gcc mailing list