Hi everyone,

i’ve some trouble with CUDA, i’m trying to launch a __global __ function from a __device __ function called by an other __global __ function which is alo called by an other __global __ function and using namespace variables. (a lot…)

To explain, i defines some constant variable in a namespace instead of using #define.I get some trouble when the compilator said :

“error : expression must have a constant value”

I guess this error come from CUDA, 'cause my variable is const, and this code works properly in C++. If i change theses variable with random set, i get another error in the call of the kernel function :

“error : cannot pass an argument with a user-provided copy-constructor to a device-side kernel launch”

But there i don’t know where the error come from.

I need some help for those both problem.

Thank to all !

Want some code ?

```
namespace global
{
Global global;
const double m_ITURadEarth = 6378145.0;
const double m_ITUGravCst = 3.986012E5;
const double m_ITUJ2 = 0.001082636;
const double m_J2000AngleDeg = 0; //-79.8058;
const double m_J2000AngleRad = 0; //TO_RAD(_J2000AngleDeg);
const double m_ITUAngleRateEarthRot = 4.1780745823E-3;
const double m_ITUAngleRateEarthRotRad = global.degToRad(m_ITUAngleRateEarthRot);
const double m_pi = 3.14159265358979323846;
const double m_2pi = 2 * m_pi;
//////////////////////////////////////
Variables used by Kernel(s) function //
//////////////////////////////////////
// Main Kernel Function
const double m_simulationDuration = 615359.772; // time in second
const double m_step = 0.771;
const double m_nbItKernel = m_simulationDuration / m_step;
const int m_nbThreadsKernel = 1024;
const int m_nbBlocksKernel = (m_nbThreadsKernel - 1 + m_nbItKernel) / m_nbThreadsKernel;
// Kernel for Satelite propagator
const double m_nbSat = 1;
const int m_nbThreadsSat = 128;
const int m_nbBlocksSat = (m_nbThreadsSat - 1 + m_nbSat) / m_nbThreadsSat;
// Kernel for alpha angle (smallest angle possible on the Geostat orbit)
const double m_nbItAngle = 628319;
const double m_stepAngle = 1E-5;
const int m_nbThreadsAngle = 1024;
const int m_nbBlocksAngle = (m_nbThreadsAngle - 1 + m_nbItAngle) / m_nbThreadsAngle;
}
__device__ void alphaAngle(Cartesian EarthStation, Cartesian Sat)
{
double CUDA_result[global::m_nbBlocksAngle], angle;
int CUDA_tid[m_nbBlocksAngle], index;
Cartesian GeoSat;
/*GeoSat = findStartArcGeo(EarthStation);*/
kernelAngle << < global::m_nbBlocksAngle, global::m_nbThreadsAngle >> > (EarthStation, Sat, GeoSat, CUDA_result, CUDA_tid);
angle = getMinusAngle(CUDA_result);
index = getIndexPosition(CUDA_result, CUDA_tid);
printf //
}
```

The error occurs on :

```
global::m_nbBlocksAngle
```

Oh and i wanna know something else. I’m coding on VisualStudio 2013 with CUDA7.5 and i wanna know if it’s possible for visual Studio to recognise “<<<” and _syncthreads(); as a valid syntax ?