Bug in cuda_runtime_api.h

The following is taken from cuda_runtime_api.h, and is in IMHO wrong, as it renders the function completely useless:

extern __host__ cudaError_t CUDARTAPI cudaGetTextureReference(const struct textureReference **texref, const char *symbol);

(Note the “const” before “struct textureReference **”)

By the way, the manual does not contain that error.

I just fixed it by removing the “const”; is there anything I should be aware of?

Thanks,

Robert

The const applies to the textureReference struct, not the pointer to a pointer passed in. The rest of the 1.0 API takes const textureReferences, so the function doesn’t appear to have a problem (unless you are planning to change the internals of the returned textureReference).

In CUDA 3.2, Declaring textureReference as const do not serve the purpose to modify its members.

In the file cuda_runtime_api.h, changing the following line

extern __host__ cudaError_t CUDARTAPI cudaGetTextureReference(const struct textureReference **texref, const char *symbol);

to the line

extern __host__ cudaError_t CUDARTAPI cudaGetTextureReference(struct textureReference **texref, const char *symbol);

solves the problem for me too.

In C++ you can use:

const textureReference* constTexRefPtr=NULL;

textureReference* texRefPtr=NULL;

texRefPtr = const_cast<textureReference*>( constTexRefPtr );

cudaGetTextureReference(&constTexRefPtr, "MyTexture");

texRefPtr->normalized = true; // cannot do this with constTexRefPtr.

without modifying cuda_runtime_api.h.