gpt4 book ai didi

c - 对于 中的 bool 类型,eclipse cdt 格式化程序的行为不正确

转载 作者:太空狗 更新时间:2023-10-29 15:32:37 25 4
gpt4 key购买 nike

我在 debian 上遇到了 eclipse cdt 3.8.0 格式化程序的问题。当它自动格式化我的代码时,函数返回 bool 和 block 注释之间的换行符被删除,如下所示:这是 C 源文件中的一个问题,仅适用于 bool 类型请帮我解决这个问题:

#include <stdbool.h>

/* my comment 1 */
void foo(void);

/* my comment 2 */bool is_valid(void);

/* my comment 3 */
int cool(void);

我想要这个:

#include <stdbool.h>

/* my comment 1 */
void foo(void);

/* my comment 2 */
bool is_valid(void);

/* my comment 3 */
int cool(void);

当我评论#include <stdbool.h>并插入以下代码。格式化程序正确运行

typedef int bool;
#define true 1
#define false 0

当然,当我插入以下代码而不是上面的代码时,问题仍然存在。

#define bool int
#define true 1
#define false 0

formmater 似乎对宏没有正确的作用

最佳答案

我找到了一个解决方案,但这不是一个完整的答案。我注意到这是 eclipse cdt 格式化程序不理解 bool 类型的错误。但是当我使用双斜杠注释而不是斜杠星号注释时,格式化程序不会连接这两行,并且由于双斜杠注释是在 C99 中引入的,所以它可以在那里工作。

/* my comment 1 */
void foo(void);

// my comment 2
bool is_valid(void);

/* my comment 3 */
int cool(void);

当然我觉得上面的问题需要反馈给ecl​​ipse DEV team。有谁知道应该在哪里报告?

关于c - 对于 <stdbool.h> 中的 bool 类型,eclipse cdt 格式化程序的行为不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26647076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com