cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Tasp
Journeyman III

(Minor) Preprocessor bug?

error: extra text after expected end of preprocessing directive

  #if defined X or defined Y

                  ^

It compiles fine with the Intel SDK.



0 Likes
6 Replies
himanshu_gautam
Grandmaster

Can you please explain in some more detail. Also mention your system details: CPU,GPU,SDK,Driver&OS.

Some time back i had encountered a similar bug and reported to developers, it might be the same issue again.

0 Likes

Ubuntu 10.04, amd-app-sdk-v2.4-lnx64, Cypress GPU

When compiling I add options "-DX -DY", then I do:

#if defined X or defined Y
... 

And get a compile error (only with AMD SDK, not Intel).
My workaround looks like this:

#ifdef X
#define XY
#elif defined Y
#define XY
#endif

#ifdef XY
... 

0 Likes

Tasp,

Can you try running matrixMultiplication Double sample on your system for both GPU & CPU? This sample also declares preprocessor definitions at build time.

0 Likes

Yes the sample works but it has nothing to do with my problem as far as I can see. I'll try to explain it again:

 

Example in c:


#include <stdio.h>

#define Y

int main(int argc, char* argv[])
{
#if defined X or defined Y
    printf("Test1\n");
#endif

#if defined X || defined Y
    printf("Test2\n");
#endif
   
    return 0;
}


I expected both constructs to work in OpenCL but only the second one works.
So:

#if defined X or defined Y
in any kernel >>>> ERROR
#if defined X || defined Y
is ok

0 Likes
Tasp
Journeyman III

Just for completeness, it's defined in here http://en.wikipedia.org/wiki/Iso646.h and part of the C standard.

 

0 Likes

Reading the Wikipedia article, it appears that or is mapped to || in iso646.h. It's only defined in the language in C++98, but OpenCL is based on C99. As such, if you wanted to use or instead of ||, you would need this header file which doesn't exist.

0 Likes