Astyle 代码格式化

发布于 2024-11-03 14:55:25 字数 767 浏览 4 评论 0原文

我正在编写一个 Linux 内核模块,并尝试使用 astyle 来帮助我遵循编码标准。它似乎错误地格式化了 spi_driver 结构,我想知道是否有人知道原因。这是传递给 astyle 之前的代码(使用命令 astyle --style=linux lightmod.c):

static struct spi_driver light_driver = {
    .driver = {
            .name = "light",
            .owner = THIS_MODULE,
    },
    .probe = light_probe,
    .remove = __devexit_p(light_remove),
};

这是输出:

static struct spi_driver light_driver = {
    .driver = {
            .name = "light",
            .owner = THIS_MODULE,
    },
    .probe = light_probe,
             .remove = __devexit_p(light_remove),
               };

为什么它缩进 .remove this方式?有谁知道吗?

I'm writing a linux kernel module, and trying to use astyle to help me follow the coding standard. It seems to be formatting a spi_driver structure incorrectly and I'm wondering if anyone knows why. This is the code before passing to astyle (with the command astyle --style=linux lightmod.c):

static struct spi_driver light_driver = {
    .driver = {
            .name = "light",
            .owner = THIS_MODULE,
    },
    .probe = light_probe,
    .remove = __devexit_p(light_remove),
};

And this is the output:

static struct spi_driver light_driver = {
    .driver = {
            .name = "light",
            .owner = THIS_MODULE,
    },
    .probe = light_probe,
             .remove = __devexit_p(light_remove),
               };

Why is it indenting .remove this way? Does anyone know?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花伊自在美 2024-11-10 14:55:25

我认为这没有什么深层次的原因。 Astyle 似乎无法正确处理 C99 的指定初始值设定项。如果您使用旧式初始化程序,它可以很好地格式化它们。

I don't think that there is a deep reason for this. Astyle simply seems not be able to handle C99's designated initializers correctly. If you use oldstyle initializers it formats them fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文