Cannot specify include directory to opencl compiler

Hi all,
According to Khronos specs, it must be possible to specify as compiler option an include directory.
As far as I can see, the option does not interpret pathnames with spaces correctly, even if the pathname is enclosed in double quotes. When I replace the pathname (see below) by “C:\TEST”, no clang-error is reported.
Can you see if I do something wrong?

-I “c:\Users\Jan\Documents\Visual Studio 2008\Projects\triangularnbody\nbody-ring-test-opencl”
clang: Too many positional arguments specified!
Can specify at most 1 positional arguments: See: clang --help

I solved the problem for now by resorting to a windows-function (GetShortPathName()), introducing a platform-dependency:

int lenghth=GetShortPathName(buffer,buf2,sizeof(buf2));
sprintf(buffer,"%s -I %s",OPENCL_OPTIONS,buf2);
int cl_build_err=clBuildProgram(clprog, 0, NULL, buffer, NULL, NULL);



I tried the same code in my ocl programm. It works but what if I want to specify a subdir of cwd as my include dir for example src/header. I tried the following:

char* buffer1 = (char*) malloc(100*sizeof(char)); 

	char* buffer2 = (char*) malloc(100*sizeof(char)); 

	_getcwd(buffer1, 100);

	sprintf(buffer1, "%s\src\header", buffer1);

	int tmp_length = GetShortPathName(buffer1, buffer2, 100);

	sprintf(buffer1, "-I %s", buffer2);

But if I build the program I get an exception but no error message and the compiler prints out a lot of strange symbols. Any advice how to fix it?



Tried my code with:

sprintf(buffer,"%s -I %s\\include",OPENCL_OPTIONS,buf2);  // puts in an additional include subdir

This is after the GetShortPathName() call.

Then copied the header file into the include dir and renamed it to make sure that a positive result would be valid.

This worked.

So, maybe your buffers are a bit small, or the GetShortPathName() does something funny. You could check this in debug mode.

Since I’m not using ocl stuff, I allocate a buffer also for clGetProgramBuildInfo(); if you see logs of strange characters, maybe that buffer (alloced by the ocl library?) could be too small.

Hope this helps,