texture is not a template cannot resolve the symbol 'texture'.

I am trying to migrate a piece of ancient CUDA 4.2 code to CUDA 9.0, and struggling with a simple but hard to solve problem. My code is as the belowing:

#include “Core.cuh”
#include “texture_types.h”
#include “cuda_runtime.h”
#include “device_launch_parameters.h”
#include <stdlib.h>

texture<short, cudaTextureType3D, cudaReadModeNormalizedFloat> gTexDensity;
texture<short, cudaTextureType3D, cudaReadModeNormalizedFloat> gTexGradientMagnitude;
texture<float, cudaTextureType3D, cudaReadModeElementType> gTexExtinction;
texture<float, cudaTextureType1D, cudaReadModeElementType> gTexOpacity;
texture<float4, cudaTextureType1D, cudaReadModeElementType> gTexDiffuse;
texture<float4, cudaTextureType1D, cudaReadModeElementType> gTexSpecular;
texture<float, cudaTextureType1D, cudaReadModeElementType> gTexRoughness;
texture<float4, cudaTextureType1D, cudaReadModeElementType> gTexEmission;
texture<uchar4, cudaTextureType2D, cudaReadModeNormalizedFloat> gTexRunningEstimateRgba;

I use visual studio 2015, and the resharper notifies me with:
texture is not a template, cannot resolve symbol ‘texture’.
It seems that I am missing some header file to be included, but I don’t know what it is in CUDA 9.0.
Can anyone here help me with this. Thanks a lot in advance!


I’m not sure what a “resharper” is.

Anyway if this is a intellisense error, it may be a non-issue. Try actually compiling the code. Is the code in a .cu file or in a .cpp file?

ReSharper is a VisualStudio plugin by JetBrains that provides some of the functionality of their CLion IDE.
I have no personal experience with it, but given that neither VisualStudio nor CLion support the CUDA kernel launch syntax in their online syntax checkers it seems a safe bet that ReSharper also doesn’t.

You might find some tips by googling CLion and CUDA, telling you how to create a header file with dummy definitions to keep CLion/ReSharper’s syntax analysis happy.

Unfortunately it is not just an intellisense error, it’s a real issue. The actual compiling reports an error “texture is not a template”. The code is in a .cu file.

I did an analysis about the vs2015 solution and project, and found that the cuda 9.0 examples solution is actually created in vs2015 by a NVIDIA CUDA 9.0 runtime project template. However, my ancient code is for CUDA 4.2 and I use cmake to configure and generate the vs2015 solution. Maybe this is the cause? I have no idea.