开发者

Close a file pointer in Cuda (nvcc)

开发者 https://www.devze.com 2023-02-24 21:07 出处:网络
In gcc, the close function is used to close the file pointer. However my nvcc complier will not allow that. I can\'t seem to find a cuda-specific call or alias.

In gcc, the close function is used to close the file pointer. However my nvcc complier will not allow that. I can't seem to find a cuda-specific call or alias.

Is there a special cuda file pointer close?

This is the error I get. error: identifier "close" is undefined

For this simple code; FILE* fp = fopen(filename,"r"); if(fp ==开发者_开发技巧 NULL) { return NULL; }

close(fp);


When NVCC compiles your .cu file, it delegates the compilation of the C/C++ parts of the file to your native C/C++ compiler (gcc in your case). So, the error is coming from gcc.

You need to check why gcc is producing this error for the code in this file. Most probably, you have not included the necessary header file where close() is defined, unistd.h. Or try fclose() as another commenter has suggested.

0

精彩评论

暂无评论...
验证码 换一张
取 消