This is a bug in the command line space handling, it is not (at least on recent NVIDIA platforms) working as a standard Unix (or at least Windows) commandline should.
I've tried putting many braces, including \' \" \\" \\'
and the backtick `
. I've even tried escaping the space itself (-D OutputType=unsigned\ char
). This does not help, the command line string is probably simply chopped to tokens based on positions of spaces, and noone seems to care about braces.
One solution is to read the source code in a string, and prefix it with a single-line:
#define OutputType unsigned char
There is, however, one simpler solution. You need to include the following macro in your files:
#define MKTWOWORD(a,b) a b
And then you can use any of:
status = clBuildProgram(output_program, 1, devices,
"-D OutputType=MKTWOWORD(unsigned,char)", 0, 0);
status = clBuildProgram(output_program, 1, devices,
"-D OutputType=MKTWOWORD(unsigned,int)", 0, 0);
status = clBuildProgram(output_program, 1, devices,
"-D OutputType=MKTWOWORD(signed,int)", 0, 0);
status = clBuildProgram(output_program, 1, devices,
"-D OutputType=int", 0, 0);
The advantage is that you have to do string processing only on the commandline and not on the whole source code.
It's a bummer, but getting the MKTWOWORD macro inside the source code using the -D option is not possible, as it would result in a chiken-or-egg problem. You just have to include that in your kernels.