I am currently trying to build kernel with a header. I use clBuildProgram and include various directories in the options parameter.
After going through several headers, the OpenCL compiler reaches the following error:
Fail to build the program
“/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h”, line 40
identifier “__builtin_va_list” is undefined
typedef __builtin_va_list __gnuc_va_list;
How do you define __builtin_va_list?
Something you are
#include’ing is trying to #include stdarg.h, which is likely not compatible with OpenCL C99. Check your includes (and their includes) to find the culprit.
I suspected as much. I read somewhere that the OpenCL compiler had troubles with system header files, but I was hoping a second opinion would prove me wrong. I am using OpenCL 1.2, but is it safe to assume that it doesn’t work for later versions as well?
Of course. For example, and system header that includes file system access, system clock access, stdio access, etc. None of these can be accessed from the device.
July 30, 2015, 4:00am
The simple fix for this is to wrap any system includes needed by the host in
guards, e.g.: #ifndef OPENCL_VERSION
/* Header file shared by host and device */
// Define shared data types
#ifndef OPENCL_VERSION worked in stopping the errors. However, I hit a dead-end when I reached custom types. Thanks for the inputs.