How to disable errors / warnings in Eclipse due to OpenCL / CUDA syntax?

I use Eclipse as an OpenCL editor, and I turned on syntax highlighting for files *.clto behave like C ++ code. It works great, but all my code is underlined as syntax errors. Is there a way that I can highlight syntax highlighting and disable errors / warnings only for my files *.cl?

+3
source share
2 answers

First, Eclipse syntax syntax is programmed in C and C ++ grammar, not OpenCL, so it does not know OpenCL syntax extensions such as

, , .

#define __kernel 
#define __global

, ,

#define float2 float

#defines , OpenCL, Eclipse. Eclipse .

#ifndef __OPENCL_VERSION__
/* Define out keywords causing errors */ 
#endif

, Eclipse.

- CDT ( Eclipse, , , ), OpenCL, .

+5

ggrussel , , eclipse ( Kepler).

  • , CL. .

    #ifndef __OPENCL_VERSION__
    
    #define kernel
    #define global
    #define constant
    #define local
    
    typedef struct float2 {
      float x, y;
    } float2;
    typedef struct float3 {
      float x, y, z;
      float2 xy, xz, yx, yz, zx, zy;
    } float3;
    typedef struct float4 {
      float x, y, z, w;
      float2 xy, yx;
      float3 xyz, xzy, yxz, yzx, zxy, zyx;
    } float4;
    ... etc
    
    #endif
    

    , , . , vec8, script, .

  • (Window > Preferences) C/++ > . *.cl ++ .

  • *.cl , > properties > C/++ Build > Settings > Exclude from build.

, CL , .

CL, OpenCL swizzling:

#include "eclipseFakeOpenCL.h"

kernel void nextIntersect() {
  float4 a,b;

  a.xzy = (float3)(1.0, 1.0, 0.0);
  b.xy = a.yx;
}
+1

Source: https://habr.com/ru/post/1772850/


All Articles