如何在Eclipse中关闭由于OpenCL / CUDA语法的错误/警告? [英] How to turn off errors/warnings in Eclipse due to OpenCL/CUDA syntax?

查看:414
本文介绍了如何在Eclipse中关闭由于OpenCL / CUDA语法的错误/警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse作为OpenCL的编辑器,并且我开启了 * .cl 文件的语法高亮显示,就像C ++代码。它工作伟大,但所有我的代码下划线作为语法错误。有一种方法,我可以让我的语法高亮和关闭错误/警告只是为我的 *。cl 文件?

I am using Eclipse as an editor for OpenCL and I turned on syntax highlighting for *.cl files to behave like C++ code. It works great, but all my code is underlined as syntax errors. Is there a way that I can have my syntax highlighting and turn off the errors/warnings just for my *.cl files?

推荐答案

首先,Eclipse语法荧光笔被编程为C和C ++的语法,而不是OpenCL,因此它不知道OpenCL的语法扩展,例如

First, the Eclipse syntax highlighter is programmed to the grammar of C and C++, and not OpenCL, so it is unaware of the syntactic extensions of OpenCL, such as


  • 新关键字

  • 新数据类型

我建议新关键字可以有条件地定义为无用例如

I suggest that the new keywords can be conditionally defined to nothing e.g.

#define __kernel 
#define __global

,可以类似地处理额外的类型名,例如

and the extra typenames can be treated similarly e.g.

#define float2 float

#defines需要保护,以便仅在Eclipse编辑器中应用于编译OpenCL代码。可以在Eclipse首选项中设置定义,也可以在内核代码本身中设置。

The #defines need guarded so as not to apply in compilation of the OpenCL code, only in the Eclipse editor. Defines can be set in the Eclipse preferences, or guarded in the kernel code itself.

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

它删除了Eclipse中导航视图中函数的重载之间的区别。

This will have a slight problem in that it removes the distinction between overloads in functions in navigation views in Eclipse.

理想的答案是重新编写CDT编辑器(Eclipse中解析你输入的文本的部分,并对此进行分析)了解OpenCL,但这将是一项巨大的努力。

The ideal answer is to reprogram the CDT editor (the part of Eclipse that parses the text you type, and performs analysis on that) to be aware of OpenCL, but that would be a substantial effort.

这篇关于如何在Eclipse中关闭由于OpenCL / CUDA语法的错误/警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆