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 and Mylyn : how to disable grey files in t
- Achieving the equivalent of a variable-length (loc
- The behavior of __CUDA_ARCH__ macro
- Installing Pydev for Eclipse throws error
- Error in Scala Compiler: java.lang.AssertionError:
相关文章
- selenium+eclipse 打开网页时报错
- Eclipse failing to open
- How to downgrade to cuda 10.0 in arch linux?
- Eclipse how can I indent C++ preprocessor macros
- Why is FindBugs ignoring my check for null?
- Eclipse cleanup - what are the “.index” files - ca
- Eclipse plugin to find out unused methods in a cla
- Spring NamespaceHandler issue when launching Maven
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.
and the extra typenames can be treated similarly e.g.
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.
This will have a slight problem in that it removes the distinction between overloads in functions in navigation views in Eclipse.
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.
In addition to the answer by ggrussel I have made the following steps that give me an acceptable syntax highlighting while avoiding other problems with eclipse (tested for Kepler).
Create a header file that is included in all CL files. The header file should have guarded defines for keywords and fake structures for built-in datatypes.
Note that you need to define every possible combination of accesses to the primitive datatypes as if they where their own fields. Since this may become quite lengthy for the larger primites such as vec8, you may want to automatically pre-generate these fields with some script if you use such primitives.
In workspace settings (Window>Preferences) add a new filetype under C/C++ > File Types. Use *.cl as the pattern and C++ Source File as type.
Note that after doing these changes you may need to close and re-open the CL files before the editor highlights them correctly.
An example of a CL file that compiles under OpenCL and that is correctly highlighted and shows swizzling: