问题描述
我正在为Eclipse CDT创建一个新的项目模板,以解决我的问题。 @Jonah Graham在回答,这得到了我最大的方式。
I'm trying to create a New Project template for Eclipse CDT in order to address my question asked here. @Jonah Graham provided a very detailed walk-through in his answer to 1 and this has gotten me most of the way.
但是,我无法弄清楚如何设置通过下拉列表指定的选项;例如方言/语言标准到设置/工具设置/ GCC C ++编译器/方言选项卡上的 ISO C ++ 11(-std = c ++ 01)
如果我想更改默认的优化或调试级别等,也会出现同样的问题。
However, I can't figure out how to set an option that is specified via a drop-down; e.g. Dialect / Language Standard to ISO C++11 (-std=c++01)
on the Settings / Tool Settings / GCC C++ Compiler / Dialect tab. The same issue would arise if I wanted to change the default Optimization or Debug levels, etc.
我以为也许可以通过类似
I thought perhaps this could be accomplished via something like
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringListOptionValues">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*cpp\.compiler\.option\.dialect\.std." />
<simple-array name="values">
<element value="gnu.cpp.compiler.dialect.c++11" />
</simple-array>
<simple name="path" value="" />
</element>
</complex-array>
</process>
不幸的是,这似乎没有任何效果(没有错误,但没有产生。 cproject文件)
Unfortunately, this doesn't seem to have any effect (no errors, but nothing in the resulting .cproject file either).
我可以通过设置其他方言标志来解决这个问题,这只是一个字符串,但是我想知道如何通过下拉列表
I can work around this by setting the "Other Dialect" flag, which is just a string, but I'd like to know how to do this via a drop-down since these come up in other places.
推荐答案
执行此选项的方法是将其视为字符串和内部将字符串值更改为枚举值。我用C99(即不是C ++)进行了测试,为此我使用了它:
The way to do this option is to treat it as a string and the internals with change the string value to the enum value. I tested it with C99 (i.e. not C++), for which I used this:
<!-- Set -std=c99 by selecting the enum in the settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.dialect\.std.*" />
<simple name="value" value="ISO C99 (-std=c99)" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
所以对于你的解决方案,我期望这将工作。请注意,该值是向用户显示的值:
So for your solution I expect this will work. Note that the value is whatever is displayed to the user:
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*cpp\.compiler\.option\.dialect\.std." />
<simple name="value" value="gnu.cpp.compiler.dialect.c++11" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
与您的版本相比,我更改了流程类型和整个 name = value
元素(从 simple-array
到 simple
加内部名称显示名称)。
Compared to your version, I changed the process type and the whole name="value"
element (from simple-array
to simple
plus internal name to display name).
这篇关于Eclipse CDT项目模板 - 设置下拉选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!