Dynamic initialization error for setting const values using math functions

I’m trying to set some const parameters in a parameters header a la

const double a = 5.;
const double b = 6.;
const double ab = pow(a,b);

which throws

error: dynamic initialization is not supported for __device__, __constant__ and __shared__ variables.

This same code in C++ works fine. As far as I can tell it’s trigger by the usage of functions such as pow or sqrt. How can I avoid this issue?

Sorry to state the obvious: Don’t use dynamic initialization of device, constant and shared variables. Just pre-compute the desired constants and stick them into your header file. I would suggest pre-computing the constants with higher than target precision for optimal results.

CUDA is not C++, it’s a subset of C++. A pretty substantial subset, but a subset nonetheless.