【问题标题】:Eclipse relative indentation with classes inherited from the namespace从命名空间继承的类的 Eclipse 相对缩进
【发布时间】:2011-12-18 13:03:42
【问题描述】:

您好,我正在尝试使 Eclipse-CDT (Indigo) 相对于公共/受保护/私有关键字缩进 C++ 类方法;但预计从某些命名空间继承的类会遇到一些麻烦;这是一个插图:

// some namespaced class
namespace BarSpace {
    class Bar {

    };
}

// as it indented by eclipse:
class Foo1 : public BarSpace::Bar {
    public:
    void foo();
};

如您所见 - eclipse 缩进 foo() 方法错误;与公众无关:keywrod。 我玩了一点,发现只有当 Foo* 类继承自命名空间类时才会发生这种情况;这种解决方法可能有效:

// workaround:
using namespace BarSpace;
class Foo2 : public Bar {
    public:
        void foo();
};

只有我不想用我的构造污染命名空间。我想同时拥有相对缩进和命名空间继承;如下:

// as i want it to be indented:
class Foo3 : public BarSpace::Bar {
    public:
        void foo();
};

如何配置 Eclipse 以按我的意愿工作? 谢谢。

【问题讨论】:

    标签: c++ eclipse eclipse-cdt indentation


    【解决方案1】:

    eclipse有一个astyle插件。安装它,你可以调整很多东西。

    astyleclipse.sourceforge.net/

    也许你的问题也可以这样解决

    【讨论】:

      【解决方案2】:

      Eclipse -> 首选项 -> C/C++ -> CodeStyle -> 格式化程序。

      截至 Eclipse Mars。

      【讨论】:

        猜你喜欢
        • 2015-07-18
        • 2017-12-10
        • 2011-01-15
        • 2013-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-13
        • 2013-09-02
        相关资源
        最近更新 更多