开发者

ATI Stream OpenCL: Problem while opening opencl kernel file in Visual Studio 2010

FILE *fp;
long filelen; long readlen;
char* src;
fp = fopen("OpenCLSource.cl","r");
fseek(fp,0L,SEEK_END);
filelen = ftell(fp);
rewind(fp);
src = (char *) malloc(sizeof(char)*(filelen+1));    
readlen = fread(src,1,filelen,fp);
src[filelen+1] = '\0';
fclose(fp);

I typed in this code, and I got an error that it's fopen is deprecated, I solved the problem by getting help from a forum i.e, I added _CRT_SECURE_NO_WARNINGS to the preprocessor definitions.

But, I STI开发者_运维技巧LL can't load the kernel file. There are "no" errors or warnings. Value of fp is ZERO Is there any alternate method to do this??

Thanks in advance


fopen is a POSIX command. For Linux the man page tells:

RETURN VALUE
   Upon successful completion fopen(), fdopen() and freopen() return a FILE
   pointer. Otherwise, NULL is returned and errno is set to indicate the error.

I think this is valid for the Windows implementation as well. You can get the the error code by checking the variable errno. A user readable string can be got with strerror:

char *str = strerror(errno);
printf("error: %s\n", str);

Hopefully, this works on Windows, too.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜