printf出错并且不显示结果 [英] printf makes error and don't show the result
问题描述
我在opencl中的printf有问题 这是我的代码的一部分:
i have problem with the printf in opencl this is the part of my code :
clGetEventProfilingInfo(timing_event, CL_PROFILING_COMMAND_START,
sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(timing_event, CL_PROFILING_COMMAND_END,sizeof(time_end),
&time_end, NULL);
total_time = time_end - time_start;
printf("\nAverage Time In Nanoseconds = %lu\n" , total_time );
我已经声明了这样的变量:
and i have declared variables like this :
cl_event timing_event;
cl_ulong time_start, time_end;
cl_ulong total_time;
但是当我编译程序mingw32-gcc时会出现此错误:
but when i compile the program mingw32-gcc makes this error :
format %lu expects argument of type 'long unsigned int' but argument 2 has type 'cl_ulong'
[-Wformat]
并且* .exe无法运行.那有什么身体可以帮助我吗?我对这个错误很困惑!!!
and the *.exe does't run . so is there any body help me ? i am so confused about this error !!!
推荐答案
cl_ulong在cl_platform中定义为:
cl_ulong is defined in cl_platform as:
typedef unsigned __int64 cl_ulong;
因此%llu是正确的.要使%llu与mingw一起使用,请在包含文件之前添加以下行:
So %llu is correct. To make %llu work with mingw, add this line before your include files:
#define __USE_MINGW_ANSI_STDIO 1
没有此定义,您必须使用非标准的Microsoft等效项%I64u.
Without this definition, you have to use the non-standard Microsoft equivalent, %I64u.
这篇关于printf出错并且不显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!