intptr_t type in OpenCL programs

When trying to compile a kernel that uses the ‘intptr_t’ type, I am getting an error for ‘use of undeclared identifier’

Is the intptr_t implemented in Clang for OpenCL?

Where would I look in the code to find out?


Al Dorrington

Software Engineer Sr

Lockheed Martin, Mission Systems and Training

Hi Albert,

The “intptr_t” type does not need special handling in Clang, since it can be created using other types. For example, the Khronos version of Clang uses the following definition in an implicit header:

Hi Sameer,

I was not aware of the Khronos SPIR Tools, thanks for the reference I will have to read up on it.

After my post to the mailing list I did find the typedef for Clang within the file: ./tools/clang/lib/Headers/stdint.h

Which, on my system, appears to be installed here: /usr/local/lib/clang/3.4/include/stdint.h

I have been building openCL kernels to IR using clang with the following command line:

clang -O0 -emit-llvm -include /usr/local/include/clc/clc.h -I /usr/local/include -Dcl_clang_storage_class_specifiers -target r600 -mcpu=turks –c –o mykernel.bc

I was expecting that the typedefs would have been part of /usr/local/include/clc/clc.h, but it does not appear to be.

If I try to add a –include for /usr/local/include/CL/cl.h, but that winds up trying to include system include files for the x86_64 platform, rather than the r600 target, and I end up with a bunch more errors.

My current assumption is that that libclc’s clctypes.h should either define these types, or include a header file such as the opencl_spir.h file.