简体   繁体   English

将预处理器添加到Eclipse CDT工具链

[英]Add pre-processor to Eclipse CDT toolchain

Is there a straightforward way to get Eclipse CDT to run the code through a pre-processor before passing through its syntax checker and whatnot to handle auto-correction and in-IDE error checking? 有没有一种简单的方法可以使Eclipse CDT在通过其语法检查器之前通过预处理器运行代码,而不必通过它来处理自动校正和IDE中的错误检查?

Ideally, if I have a pre-processor that replaces $foo with std::cout , I could then type $foo.flu and then do Ctrl + Space to correctly auto-complete to $foo.flush() . 理想情况下,如果我有一个预处理器将$foo替换$foo std::cout ,则可以键入$foo.flu ,然后执行Ctrl + Space正确地自动完成到$foo.flush()

Would this require hacking/extending CDT internally, or is there is a way to configure an existing toolchain to do this? 这是否需要在内部修改/扩展CDT,或者是否可以通过配置现有工具链来做到这一点? Even if it correctly identifies that $foo is not a syntax error without auto-completion, that would help. 即使在没有自动补全的情况下,即使它正确地标识出$foo不是语法错误,也将有所帮助。

Of course the code compiles fine (using a CMake script, not the Eclipse builder), but I'd like to be able to get Eclipse to stop showing a million errors without disabling error checking altogether. 当然,代码可以很好地编译(使用CMake脚本,而不是Eclipse构建器),但是我希望能够使Eclipse停止显示一百万个错误,而无需完全禁用错误检查。

Eclipse, as it stands, cannot and will not do this. 就目前而言,Eclipse不能也不会这样做。 Other major IDEs follow suit. 其他主要的IDE也效仿。

The reason for this is because most IDEs ship with a basic or proprietary build system that is meant to integrate seamlessly with the IDE itself. 这样做的原因是因为大多数IDE附带了一个基本或专有的构建系统,该系统旨在与IDE本身无缝集成。

Most major projects use an IDE almost as an afterthought; 大多数主要项目几乎都是在事后才使用IDE。 code is set up, a dedicated build system is wired up and configured (such as make , cmake , scons , gradle , or my personal favorite, tup ), and then the IDE is brought on to the chain simply as a visual or syntactic aid for a particular developer. 代码设置,一个专门的编译系统,有线和配置(如化妆CMake的使用SConsgradle这个 ,还是我个人最喜欢的, TUP ),然后将IDE被运至链只是作为一种视觉或句法援助针对特定的开发人员。

Most (if not all) of the aforementioned build systems support drop-in preprocessors (some are easier than others). 前面提到的大多数构建系统(如果不是全部的话)都支持嵌入式预处理器(某些预处理器比其他预处理器容易)。 Build systems are a dime a dozen and are quite easy to find . 构建系统只有一角钱, 而且很容易找到

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM