You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Betty规范编写C代码时遇print_alphabet函数注释警告求助

解决Betty编码风格检查中“无函数描述”的警告

Betty提示1-alphabet.c:11: warning: no description found for function print_alphabet,核心原因是你的函数注释格式不符合Betty的严格要求——函数声明注释行和Description字段之间不能有空行,空行导致Betty无法识别描述内容。

修正步骤

  1. 删掉* print_alphabet(void) - entry point这一行和* Description: ...行之间的空行
  2. 保证注释块内所有行开头的*对齐(同时修正了你代码里_putchar(c)的缩进问题)

修正后的代码

#include "main.h"

/**
 * print_alphabet(void) - entry point
 * Description: This function prints the alphabet, in lowercase
 * Return: void
 */

void print_alphabet(void)
{
        char c;

        for (c = 'a'; c <= 'z'; c++)
        {
                _putchar(c);
        }
        _putchar('\n');
}

Betty函数注释规范要点

  • 注释块必须以/**开头,*/结尾
  • 第一行格式固定:* 函数名(参数列表) - 简短功能说明
  • 描述、返回值等字段必须紧跟在上一行注释后,不能插入空行
  • 注释块内所有行的*要垂直对齐

内容的提问来源于stack exchange,提问作者Flames

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 11:54:55