4

我正在使用 Eclipse CDT(Helios 版本)来编辑(旧)C 应用程序的源代码,该应用程序也使用 ESQL。在这个项目中,按照惯例,包含 ESQL 代码的文件具有 .sc 扩展名(而不是默认的 .c)

所有 ESQL 部分,例如以 EXEC SQL 关键字开头的部分都被标记为“语法错误”(垂直标尺、概览标尺和琥珀色波浪线)。实际编译是在具有 ESQL 编译器的不同机器 (Unix) 上执行的。如何检查开发机器上的 SQL 代码的语法?

注意:我可以从 Preferences / General / Editors / Text Editors / Annotations / C/C++ Indexer Markers 隐藏通知,但这可能会隐藏可能有用的警告。

4

2 回答 2

0

If you use the Window->Preferences->C/C++->File Types and define a new file type with C or C++ as *.pc, or *.sc etc. as is appropriate to your extension, then the syntax highlighter will attempt to colour the keywords appropriately and provide hover tips. Of course the EXEC SQL type statements will show up as errors but those are relatively easy to ignore knowing that you're looking for some help for the elements in the file, but not all (i.e. doesn't parse embedded SQL).

Update (for vi(m) lovers): I found that I needed to create a file in ~/.vim/ftdetect/pc.vim containing:

au BufRead,BufNewFile *.pc set filetype=pc

and I also created a link from my /usr/share/vim/vim73/esqlc.vim to pc.vim (though we could have specified *.pc set filetype=esqlc)

and I installed vrapper, then after restarting eclipse, I my EXEC SQL or other keywords were no longer underlined, though they weren't colourized either. That may change in future vrapper updates. (Note: I'm using Eclipse Kepler as it supports vrapper)

Bonus: make sure to set your preferences for "Find and Replace" to CTRL-4 instead of CTRL-F to get page forward in vim working.

于 2013-09-20T22:12:50.420 回答
0

不管你怎么想,你所拥有的不是 C 代码。

额外的“语法”(例如,EXEC SQL 加上里面的任何东西)根本就不是 C 代码,任何处理传统 C 代码的工具必然会将其作为语法错误拒绝。

“ESQL 处理器”(听起来像是给定 EXEC SQL 短语的大型机)可能会预处理您对 C 代码的想法,以提取 SQL 并用函数调用替换它;该结果可能会反馈给真正的 C 编译器。

我怀疑你可以用 CDT 做任何有用的事情。

于 2010-12-30T10:36:17.917 回答