Thanks, I tried that and have exactly the following:
constants.h
const float timestep = 0.001;
main.cu
#include "constants.h"
__constant__ float d_timestep = 0.001;
__global__ void kernel(float *time)
{
time[threadIdx.x] += d_timestep;
}
int main()
{
return 0;
}
No other code. This compiles just fine, but when I change “0.001” to “timestep” the compiler gives me this:
1>------ Build started: Project: cuda_template, Configuration: Debug x64 ------
1>Compiling...
1>main.cu
1>main.cu(3): error: can't generate code for non empty constructors or destructors on device
1>1 error detected in the compilation of "C:/Users/Victor/AppData/Local/Temp/tmpxft_00001994_00000000-6_main.cpp1.ii".
1>Project : error PRJ0019: A tool returned an error code from "Compiling..."
1>Build log was saved at "file://d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BuildLog.htm"
1>cuda_template - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This is the BuildLog.html file:
Build Log
Build started: Project: cuda_template, Configuration: Debug|x64
Command Lines
Creating temporary file “d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BAT00004311805984.bat” with contents
[
@echo off
nvcc.exe -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin” -c -Xcompiler "/EHsc /W3 /nologo /Wp64 /O2 /Zi /MT " -o Debug\main.obj main.cu
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from “Compiling…”
exit 1
:VCEnd
]
Creating command line “d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BAT00004311805984.bat”
Output Window
Compiling…
main.cu
main.cu(3): error: can’t generate code for non empty constructors or destructors on device
1 error detected in the compilation of “C:/Users/Victor/AppData/Local/Temp/tmpxft_00001994_00000000-6_main.cpp1.ii”.
Project : error PRJ0019: A tool returned an error code from “Compiling…”
Results
Build log was saved at “file://d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BuildLog.htm”
cuda_template - 2 error(s), 0 warning(s)